From a43f48ad4d5a9342c1fda0e0bd07e492fe1c7ba7 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 29 Sep 2025 23:57:58 +0000 Subject: [PATCH 1/2] feat: Enable `rest` for `google-cloud-video-stitcher` PiperOrigin-RevId: 812959682 Source-Link: https://github.com/googleapis/googleapis/commit/eab82ec804dfd76372ca369910ccd0766ee02e5c Source-Link: https://github.com/googleapis/googleapis-gen/commit/8d6413492e6861c837196d24858b767b57991f89 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXZpZGVvLXN0aXRjaGVyLy5Pd2xCb3QueWFtbCIsImgiOiI4ZDY0MTM0OTJlNjg2MWM4MzcxOTZkMjQ4NThiNzY3YjU3OTkxZjg5In0= --- .../v1/.coveragerc | 13 + .../google-cloud-video-stitcher/v1/.flake8 | 34 + .../google-cloud-video-stitcher/v1/LICENSE | 202 + .../v1/MANIFEST.in | 20 + .../google-cloud-video-stitcher/v1/README.rst | 143 + .../v1/docs/_static/custom.css | 20 + .../v1/docs/_templates/layout.html | 50 + .../v1/docs/conf.py | 385 + .../v1/docs/index.rst | 10 + .../v1/docs/multiprocessing.rst | 7 + .../v1/docs/stitcher_v1/services_.rst | 6 + .../v1/docs/stitcher_v1/types_.rst | 6 + .../stitcher_v1/video_stitcher_service.rst | 10 + .../google/cloud/video/stitcher/__init__.py | 171 + .../cloud/video/stitcher/gapic_version.py | 16 + .../v1/google/cloud/video/stitcher/py.typed | 2 + .../cloud/video/stitcher_v1/__init__.py | 172 + .../video/stitcher_v1/gapic_metadata.json | 478 + .../cloud/video/stitcher_v1/gapic_version.py | 16 + .../google/cloud/video/stitcher_v1/py.typed | 2 + .../video/stitcher_v1/services/__init__.py | 15 + .../video_stitcher_service/__init__.py | 22 + .../video_stitcher_service/async_client.py | 4240 +++ .../services/video_stitcher_service/client.py | 4651 +++ .../services/video_stitcher_service/pagers.py | 1006 + .../transports/README.rst | 9 + .../transports/__init__.py | 38 + .../video_stitcher_service/transports/base.py | 635 + .../video_stitcher_service/transports/grpc.py | 1222 + .../transports/grpc_asyncio.py | 1408 + .../video_stitcher_service/transports/rest.py | 6004 ++++ .../transports/rest_base.py | 1414 + .../cloud/video/stitcher_v1/types/__init__.py | 184 + .../video/stitcher_v1/types/ad_tag_details.py | 180 + .../cloud/video/stitcher_v1/types/cdn_keys.py | 182 + .../video/stitcher_v1/types/companions.py | 240 + .../cloud/video/stitcher_v1/types/events.py | 177 + .../video/stitcher_v1/types/fetch_options.py | 50 + .../video/stitcher_v1/types/live_configs.py | 236 + .../cloud/video/stitcher_v1/types/sessions.py | 452 + .../cloud/video/stitcher_v1/types/slates.py | 83 + .../video/stitcher_v1/types/stitch_details.py | 106 + .../types/video_stitcher_service.py | 1124 + .../video/stitcher_v1/types/vod_configs.py | 118 + .../google-cloud-video-stitcher/v1/mypy.ini | 3 + .../google-cloud-video-stitcher/v1/noxfile.py | 591 + ...tadata_google.cloud.video.stitcher.v1.json | 4957 +++ ...o_stitcher_service_create_cdn_key_async.py | 57 + ...eo_stitcher_service_create_cdn_key_sync.py | 57 + ...itcher_service_create_live_config_async.py | 62 + ...titcher_service_create_live_config_sync.py | 62 + ...tcher_service_create_live_session_async.py | 56 + ...itcher_service_create_live_session_sync.py | 56 + ...deo_stitcher_service_create_slate_async.py | 57 + ...ideo_stitcher_service_create_slate_sync.py | 57 + ...titcher_service_create_vod_config_async.py | 62 + ...stitcher_service_create_vod_config_sync.py | 62 + ...itcher_service_create_vod_session_async.py | 56 + ...titcher_service_create_vod_session_sync.py | 56 + ...o_stitcher_service_delete_cdn_key_async.py | 56 + ...eo_stitcher_service_delete_cdn_key_sync.py | 56 + ...itcher_service_delete_live_config_async.py | 56 + ...titcher_service_delete_live_config_sync.py | 56 + ...deo_stitcher_service_delete_slate_async.py | 56 + ...ideo_stitcher_service_delete_slate_sync.py | 56 + ...titcher_service_delete_vod_config_async.py | 56 + ...stitcher_service_delete_vod_config_sync.py | 56 + ...ideo_stitcher_service_get_cdn_key_async.py | 52 + ...video_stitcher_service_get_cdn_key_sync.py | 52 + ...er_service_get_live_ad_tag_detail_async.py | 52 + ...her_service_get_live_ad_tag_detail_sync.py | 52 + ..._stitcher_service_get_live_config_async.py | 52 + ...o_stitcher_service_get_live_config_sync.py | 52 + ...stitcher_service_get_live_session_async.py | 52 + ..._stitcher_service_get_live_session_sync.py | 52 + ..._video_stitcher_service_get_slate_async.py | 52 + ...d_video_stitcher_service_get_slate_sync.py | 52 + ...her_service_get_vod_ad_tag_detail_async.py | 52 + ...cher_service_get_vod_ad_tag_detail_sync.py | 52 + ...o_stitcher_service_get_vod_config_async.py | 52 + ...eo_stitcher_service_get_vod_config_sync.py | 52 + ..._stitcher_service_get_vod_session_async.py | 52 + ...o_stitcher_service_get_vod_session_sync.py | 52 + ...her_service_get_vod_stitch_detail_async.py | 52 + ...cher_service_get_vod_stitch_detail_sync.py | 52 + ...eo_stitcher_service_list_cdn_keys_async.py | 53 + ...deo_stitcher_service_list_cdn_keys_sync.py | 53 + ..._service_list_live_ad_tag_details_async.py | 53 + ...r_service_list_live_ad_tag_details_sync.py | 53 + ...titcher_service_list_live_configs_async.py | 53 + ...stitcher_service_list_live_configs_sync.py | 53 + ...ideo_stitcher_service_list_slates_async.py | 53 + ...video_stitcher_service_list_slates_sync.py | 53 + ...r_service_list_vod_ad_tag_details_async.py | 53 + ...er_service_list_vod_ad_tag_details_sync.py | 53 + ...stitcher_service_list_vod_configs_async.py | 53 + ..._stitcher_service_list_vod_configs_sync.py | 53 + ...r_service_list_vod_stitch_details_async.py | 53 + ...er_service_list_vod_stitch_details_sync.py | 53 + ...o_stitcher_service_update_cdn_key_async.py | 55 + ...eo_stitcher_service_update_cdn_key_sync.py | 55 + ...itcher_service_update_live_config_async.py | 60 + ...titcher_service_update_live_config_sync.py | 60 + ...deo_stitcher_service_update_slate_async.py | 55 + ...ideo_stitcher_service_update_slate_sync.py | 55 + ...titcher_service_update_vod_config_async.py | 60 + ...stitcher_service_update_vod_config_sync.py | 60 + .../v1/scripts/fixup_stitcher_v1_keywords.py | 205 + .../google-cloud-video-stitcher/v1/setup.py | 98 + .../v1/testing/constraints-3.10.txt | 6 + .../v1/testing/constraints-3.11.txt | 6 + .../v1/testing/constraints-3.12.txt | 6 + .../v1/testing/constraints-3.13.txt | 11 + .../v1/testing/constraints-3.7.txt | 10 + .../v1/testing/constraints-3.8.txt | 6 + .../v1/testing/constraints-3.9.txt | 6 + .../v1/tests/__init__.py | 16 + .../v1/tests/unit/__init__.py | 16 + .../v1/tests/unit/gapic/__init__.py | 16 + .../tests/unit/gapic/stitcher_v1/__init__.py | 16 + .../test_video_stitcher_service.py | 25166 ++++++++++++++++ 121 files changed, 59980 insertions(+) create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/README.rst create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/setup.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc b/owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc new file mode 100644 index 000000000000..d8fd2d427e9a --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/video/stitcher/__init__.py + google/cloud/video/stitcher/gapic_version.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 b/owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 new file mode 100644 index 000000000000..90316de21489 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +[flake8] +# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): +# Resolve flake8 lint issues +ignore = E203, E231, E266, E501, W503 +exclude = + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): + # Ensure that generated code passes flake8 lint + **/gapic/** + **/services/** + **/types/** + # Exclude Protobuf gencode + *_pb2.py + + # Standard linting exemptions. + **/.nox/** + __pycache__, + .git, + *.pyc, + conf.py diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE b/owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in b/owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in new file mode 100644 index 000000000000..dae249ec8976 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +include README.rst LICENSE +recursive-include google *.py *.pyi *.json *.proto py.typed +recursive-include tests * +global-exclude *.py[co] +global-exclude __pycache__ diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/README.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/README.rst new file mode 100644 index 000000000000..bc5dade72671 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/README.rst @@ -0,0 +1,143 @@ +Python Client for Google Cloud Video Stitcher 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 Video Stitcher 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 + + +Logging +------- + +This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes. +Note the following: + +#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging. +#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**. +#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below. + + +Simple, environment-based configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google +logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged +messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging +event. + +A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log. + +- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc. +- Invalid logging scopes: :code:`foo`, :code:`123`, etc. + +**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers. + + +Examples +^^^^^^^^ + +- Enabling the default handler for all Google-based loggers + +.. code-block:: console + + export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google + +- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`): + +.. code-block:: console + + export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1 + + +Advanced, code-based configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can also configure a valid logging scope using Python's standard `logging` mechanism. + + +Examples +^^^^^^^^ + +- Configuring a handler for all Google-based loggers + +.. code-block:: python + + import logging + + from google.cloud.translate_v3 import translate + + base_logger = logging.getLogger("google") + base_logger.addHandler(logging.StreamHandler()) + base_logger.setLevel(logging.DEBUG) + +- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`): + +.. code-block:: python + + import logging + + from google.cloud.translate_v3 import translate + + base_logger = logging.getLogger("google.cloud.library_v1") + base_logger.addHandler(logging.StreamHandler()) + base_logger.setLevel(logging.DEBUG) + + +Logging details +~~~~~~~~~~~~~~~ + +#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root + logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set + :code:`logging.getLogger("google").propagate = True` in your code. +#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for + one library, but decide you need to also set up environment-based logging configuration for another library. + + #. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual + if the code -based configuration gets applied first. + +#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get + executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured. + (This is the reason for 2.i. above.) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css new file mode 100644 index 000000000000..b0a295464b23 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css @@ -0,0 +1,20 @@ +div#python2-eol { + border-color: red; + border-width: medium; +} + +/* Ensure minimum width for 'Parameters' / 'Returns' column */ +dl.field-list > dt { + min-width: 100px +} + +/* Insert space between methods for readability */ +dl.method { + padding-top: 10px; + padding-bottom: 10px +} + +/* Insert empty space between classes */ +dl.class { + padding-bottom: 50px +} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html new file mode 100644 index 000000000000..95e9c77fcfe1 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html @@ -0,0 +1,50 @@ + +{% extends "!layout.html" %} +{%- block content %} +{%- if theme_fixed_sidebar|lower == 'true' %} +
+ {{ sidebar() }} + {%- block document %} +
+ {%- if render_sidebar %} +
+ {%- endif %} + + {%- block relbar_top %} + {%- if theme_show_relbar_top|tobool %} + + {%- endif %} + {% endblock %} + +
+
+ As of January 1, 2020 this library no longer supports Python 2 on the latest released version. + Library versions released prior to that date will continue to be available. For more information please + visit Python 2 support on Google Cloud. +
+ {% block body %} {% endblock %} +
+ + {%- block relbar_bottom %} + {%- if theme_show_relbar_bottom|tobool %} + + {%- endif %} + {% endblock %} + + {%- if render_sidebar %} +
+ {%- endif %} +
+ {%- endblock %} +
+
+{%- else %} +{{ super() }} +{%- endif %} +{%- endblock %} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py new file mode 100644 index 000000000000..eaab15dec8d1 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py @@ -0,0 +1,385 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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-video-stitcher 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("..")) + +# For plugins that can not read conf.py. +# See also: https://github.com/docascode/sphinx-docfx-yaml/issues/85 +sys.path.insert(0, os.path.abspath(".")) + +__version__ = "" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "4.5.0" + +# 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.doctest", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", + "recommonmark", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_options = {"members": True} +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +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-video-stitcher" +copyright = u"2025, Google, LLC" +author = u"Google APIs" + +# 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", + "**/.nox/**/*", + "samples/AUTHORING_GUIDE.md", + "samples/CONTRIBUTING.md", + "samples/snippets/README.rst", +] + +# 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 Video Client Libraries for google-cloud-video-stitcher", + "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-video-stitcher-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-video-stitcher.tex", + u"google-cloud-video-stitcher 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-video-stitcher", + "google-cloud-video-stitcher 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-video-stitcher", + "google-cloud-video-stitcher Documentation", + author, + "google-cloud-video-stitcher", + "google-cloud-video-stitcher Library", + "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": ("https://python.readthedocs.org/en/latest/", None), + "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), + "grpc": ("https://grpc.github.io/grpc/python/", None), + "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst new file mode 100644 index 000000000000..ed4637468133 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst @@ -0,0 +1,10 @@ +.. include:: multiprocessing.rst + + +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + stitcher_v1/services_ + stitcher_v1/types_ diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst new file mode 100644 index 000000000000..536d17b2ea65 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst @@ -0,0 +1,7 @@ +.. note:: + + Because this client uses :mod:`grpc` library, it is safe to + share instances across threads. In multiprocessing scenarios, the best + practice is to create client instances *after* the invocation of + :func:`os.fork` by :class:`multiprocessing.pool.Pool` or + :class:`multiprocessing.Process`. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst new file mode 100644 index 000000000000..413e5a0db521 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Video Stitcher v1 API +=============================================== +.. toctree:: + :maxdepth: 2 + + video_stitcher_service diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst new file mode 100644 index 000000000000..3d8d2580c1c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst @@ -0,0 +1,6 @@ +Types for Google Cloud Video Stitcher v1 API +============================================ + +.. automodule:: google.cloud.video.stitcher_v1.types + :members: + :show-inheritance: diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst new file mode 100644 index 000000000000..5052a0d9045f --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst @@ -0,0 +1,10 @@ +VideoStitcherService +-------------------------------------- + +.. automodule:: google.cloud.video.stitcher_v1.services.video_stitcher_service + :members: + :inherited-members: + +.. automodule:: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py new file mode 100644 index 000000000000..e739eb58f275 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py @@ -0,0 +1,171 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher import gapic_version as package_version + +__version__ = package_version.__version__ + + +from google.cloud.video.stitcher_v1.services.video_stitcher_service.client import VideoStitcherServiceClient +from google.cloud.video.stitcher_v1.services.video_stitcher_service.async_client import VideoStitcherServiceAsyncClient + +from google.cloud.video.stitcher_v1.types.ad_tag_details import AdRequest +from google.cloud.video.stitcher_v1.types.ad_tag_details import LiveAdTagDetail +from google.cloud.video.stitcher_v1.types.ad_tag_details import RequestMetadata +from google.cloud.video.stitcher_v1.types.ad_tag_details import ResponseMetadata +from google.cloud.video.stitcher_v1.types.ad_tag_details import VodAdTagDetail +from google.cloud.video.stitcher_v1.types.cdn_keys import AkamaiCdnKey +from google.cloud.video.stitcher_v1.types.cdn_keys import CdnKey +from google.cloud.video.stitcher_v1.types.cdn_keys import GoogleCdnKey +from google.cloud.video.stitcher_v1.types.cdn_keys import MediaCdnKey +from google.cloud.video.stitcher_v1.types.companions import Companion +from google.cloud.video.stitcher_v1.types.companions import CompanionAds +from google.cloud.video.stitcher_v1.types.companions import HtmlAdResource +from google.cloud.video.stitcher_v1.types.companions import IframeAdResource +from google.cloud.video.stitcher_v1.types.companions import StaticAdResource +from google.cloud.video.stitcher_v1.types.events import Event +from google.cloud.video.stitcher_v1.types.events import ProgressEvent +from google.cloud.video.stitcher_v1.types.fetch_options import FetchOptions +from google.cloud.video.stitcher_v1.types.live_configs import GamLiveConfig +from google.cloud.video.stitcher_v1.types.live_configs import LiveConfig +from google.cloud.video.stitcher_v1.types.live_configs import PrefetchConfig +from google.cloud.video.stitcher_v1.types.live_configs import AdTracking +from google.cloud.video.stitcher_v1.types.sessions import Interstitials +from google.cloud.video.stitcher_v1.types.sessions import LiveSession +from google.cloud.video.stitcher_v1.types.sessions import ManifestOptions +from google.cloud.video.stitcher_v1.types.sessions import RenditionFilter +from google.cloud.video.stitcher_v1.types.sessions import VodSession +from google.cloud.video.stitcher_v1.types.sessions import VodSessionAd +from google.cloud.video.stitcher_v1.types.sessions import VodSessionAdBreak +from google.cloud.video.stitcher_v1.types.sessions import VodSessionContent +from google.cloud.video.stitcher_v1.types.slates import Slate +from google.cloud.video.stitcher_v1.types.stitch_details import AdStitchDetail +from google.cloud.video.stitcher_v1.types.stitch_details import VodStitchDetail +from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateCdnKeyRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateLiveConfigRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateLiveSessionRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateSlateRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateVodConfigRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateVodSessionRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteCdnKeyRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteLiveConfigRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteSlateRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteVodConfigRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetCdnKeyRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetLiveAdTagDetailRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetLiveConfigRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetLiveSessionRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetSlateRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodAdTagDetailRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodConfigRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodSessionRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodStitchDetailRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListCdnKeysRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListCdnKeysResponse +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveAdTagDetailsRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveAdTagDetailsResponse +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveConfigsRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveConfigsResponse +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListSlatesRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListSlatesResponse +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodAdTagDetailsRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodAdTagDetailsResponse +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodConfigsRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodConfigsResponse +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodStitchDetailsRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodStitchDetailsResponse +from google.cloud.video.stitcher_v1.types.video_stitcher_service import OperationMetadata +from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateCdnKeyRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateLiveConfigRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateSlateRequest +from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateVodConfigRequest +from google.cloud.video.stitcher_v1.types.vod_configs import GamVodConfig +from google.cloud.video.stitcher_v1.types.vod_configs import VodConfig + +__all__ = ('VideoStitcherServiceClient', + 'VideoStitcherServiceAsyncClient', + 'AdRequest', + 'LiveAdTagDetail', + 'RequestMetadata', + 'ResponseMetadata', + 'VodAdTagDetail', + 'AkamaiCdnKey', + 'CdnKey', + 'GoogleCdnKey', + 'MediaCdnKey', + 'Companion', + 'CompanionAds', + 'HtmlAdResource', + 'IframeAdResource', + 'StaticAdResource', + 'Event', + 'ProgressEvent', + 'FetchOptions', + 'GamLiveConfig', + 'LiveConfig', + 'PrefetchConfig', + 'AdTracking', + 'Interstitials', + 'LiveSession', + 'ManifestOptions', + 'RenditionFilter', + 'VodSession', + 'VodSessionAd', + 'VodSessionAdBreak', + 'VodSessionContent', + 'Slate', + 'AdStitchDetail', + 'VodStitchDetail', + 'CreateCdnKeyRequest', + 'CreateLiveConfigRequest', + 'CreateLiveSessionRequest', + 'CreateSlateRequest', + 'CreateVodConfigRequest', + 'CreateVodSessionRequest', + 'DeleteCdnKeyRequest', + 'DeleteLiveConfigRequest', + 'DeleteSlateRequest', + 'DeleteVodConfigRequest', + 'GetCdnKeyRequest', + 'GetLiveAdTagDetailRequest', + 'GetLiveConfigRequest', + 'GetLiveSessionRequest', + 'GetSlateRequest', + 'GetVodAdTagDetailRequest', + 'GetVodConfigRequest', + 'GetVodSessionRequest', + 'GetVodStitchDetailRequest', + 'ListCdnKeysRequest', + 'ListCdnKeysResponse', + 'ListLiveAdTagDetailsRequest', + 'ListLiveAdTagDetailsResponse', + 'ListLiveConfigsRequest', + 'ListLiveConfigsResponse', + 'ListSlatesRequest', + 'ListSlatesResponse', + 'ListVodAdTagDetailsRequest', + 'ListVodAdTagDetailsResponse', + 'ListVodConfigsRequest', + 'ListVodConfigsResponse', + 'ListVodStitchDetailsRequest', + 'ListVodStitchDetailsResponse', + 'OperationMetadata', + 'UpdateCdnKeyRequest', + 'UpdateLiveConfigRequest', + 'UpdateSlateRequest', + 'UpdateVodConfigRequest', + 'GamVodConfig', + 'VodConfig', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py new file mode 100644 index 000000000000..20a9cd975b02 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed new file mode 100644 index 000000000000..158ff5acbd28 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-video-stitcher package uses inline types. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py new file mode 100644 index 000000000000..228e190e0885 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py @@ -0,0 +1,172 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher_v1 import gapic_version as package_version + +__version__ = package_version.__version__ + + +from .services.video_stitcher_service import VideoStitcherServiceClient +from .services.video_stitcher_service import VideoStitcherServiceAsyncClient + +from .types.ad_tag_details import AdRequest +from .types.ad_tag_details import LiveAdTagDetail +from .types.ad_tag_details import RequestMetadata +from .types.ad_tag_details import ResponseMetadata +from .types.ad_tag_details import VodAdTagDetail +from .types.cdn_keys import AkamaiCdnKey +from .types.cdn_keys import CdnKey +from .types.cdn_keys import GoogleCdnKey +from .types.cdn_keys import MediaCdnKey +from .types.companions import Companion +from .types.companions import CompanionAds +from .types.companions import HtmlAdResource +from .types.companions import IframeAdResource +from .types.companions import StaticAdResource +from .types.events import Event +from .types.events import ProgressEvent +from .types.fetch_options import FetchOptions +from .types.live_configs import GamLiveConfig +from .types.live_configs import LiveConfig +from .types.live_configs import PrefetchConfig +from .types.live_configs import AdTracking +from .types.sessions import Interstitials +from .types.sessions import LiveSession +from .types.sessions import ManifestOptions +from .types.sessions import RenditionFilter +from .types.sessions import VodSession +from .types.sessions import VodSessionAd +from .types.sessions import VodSessionAdBreak +from .types.sessions import VodSessionContent +from .types.slates import Slate +from .types.stitch_details import AdStitchDetail +from .types.stitch_details import VodStitchDetail +from .types.video_stitcher_service import CreateCdnKeyRequest +from .types.video_stitcher_service import CreateLiveConfigRequest +from .types.video_stitcher_service import CreateLiveSessionRequest +from .types.video_stitcher_service import CreateSlateRequest +from .types.video_stitcher_service import CreateVodConfigRequest +from .types.video_stitcher_service import CreateVodSessionRequest +from .types.video_stitcher_service import DeleteCdnKeyRequest +from .types.video_stitcher_service import DeleteLiveConfigRequest +from .types.video_stitcher_service import DeleteSlateRequest +from .types.video_stitcher_service import DeleteVodConfigRequest +from .types.video_stitcher_service import GetCdnKeyRequest +from .types.video_stitcher_service import GetLiveAdTagDetailRequest +from .types.video_stitcher_service import GetLiveConfigRequest +from .types.video_stitcher_service import GetLiveSessionRequest +from .types.video_stitcher_service import GetSlateRequest +from .types.video_stitcher_service import GetVodAdTagDetailRequest +from .types.video_stitcher_service import GetVodConfigRequest +from .types.video_stitcher_service import GetVodSessionRequest +from .types.video_stitcher_service import GetVodStitchDetailRequest +from .types.video_stitcher_service import ListCdnKeysRequest +from .types.video_stitcher_service import ListCdnKeysResponse +from .types.video_stitcher_service import ListLiveAdTagDetailsRequest +from .types.video_stitcher_service import ListLiveAdTagDetailsResponse +from .types.video_stitcher_service import ListLiveConfigsRequest +from .types.video_stitcher_service import ListLiveConfigsResponse +from .types.video_stitcher_service import ListSlatesRequest +from .types.video_stitcher_service import ListSlatesResponse +from .types.video_stitcher_service import ListVodAdTagDetailsRequest +from .types.video_stitcher_service import ListVodAdTagDetailsResponse +from .types.video_stitcher_service import ListVodConfigsRequest +from .types.video_stitcher_service import ListVodConfigsResponse +from .types.video_stitcher_service import ListVodStitchDetailsRequest +from .types.video_stitcher_service import ListVodStitchDetailsResponse +from .types.video_stitcher_service import OperationMetadata +from .types.video_stitcher_service import UpdateCdnKeyRequest +from .types.video_stitcher_service import UpdateLiveConfigRequest +from .types.video_stitcher_service import UpdateSlateRequest +from .types.video_stitcher_service import UpdateVodConfigRequest +from .types.vod_configs import GamVodConfig +from .types.vod_configs import VodConfig + +__all__ = ( + 'VideoStitcherServiceAsyncClient', +'AdRequest', +'AdStitchDetail', +'AdTracking', +'AkamaiCdnKey', +'CdnKey', +'Companion', +'CompanionAds', +'CreateCdnKeyRequest', +'CreateLiveConfigRequest', +'CreateLiveSessionRequest', +'CreateSlateRequest', +'CreateVodConfigRequest', +'CreateVodSessionRequest', +'DeleteCdnKeyRequest', +'DeleteLiveConfigRequest', +'DeleteSlateRequest', +'DeleteVodConfigRequest', +'Event', +'FetchOptions', +'GamLiveConfig', +'GamVodConfig', +'GetCdnKeyRequest', +'GetLiveAdTagDetailRequest', +'GetLiveConfigRequest', +'GetLiveSessionRequest', +'GetSlateRequest', +'GetVodAdTagDetailRequest', +'GetVodConfigRequest', +'GetVodSessionRequest', +'GetVodStitchDetailRequest', +'GoogleCdnKey', +'HtmlAdResource', +'IframeAdResource', +'Interstitials', +'ListCdnKeysRequest', +'ListCdnKeysResponse', +'ListLiveAdTagDetailsRequest', +'ListLiveAdTagDetailsResponse', +'ListLiveConfigsRequest', +'ListLiveConfigsResponse', +'ListSlatesRequest', +'ListSlatesResponse', +'ListVodAdTagDetailsRequest', +'ListVodAdTagDetailsResponse', +'ListVodConfigsRequest', +'ListVodConfigsResponse', +'ListVodStitchDetailsRequest', +'ListVodStitchDetailsResponse', +'LiveAdTagDetail', +'LiveConfig', +'LiveSession', +'ManifestOptions', +'MediaCdnKey', +'OperationMetadata', +'PrefetchConfig', +'ProgressEvent', +'RenditionFilter', +'RequestMetadata', +'ResponseMetadata', +'Slate', +'StaticAdResource', +'UpdateCdnKeyRequest', +'UpdateLiveConfigRequest', +'UpdateSlateRequest', +'UpdateVodConfigRequest', +'VideoStitcherServiceClient', +'VodAdTagDetail', +'VodConfig', +'VodSession', +'VodSessionAd', +'VodSessionAdBreak', +'VodSessionContent', +'VodStitchDetail', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json new file mode 100644 index 000000000000..92a8e4a173a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json @@ -0,0 +1,478 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.video.stitcher_v1", + "protoPackage": "google.cloud.video.stitcher.v1", + "schema": "1.0", + "services": { + "VideoStitcherService": { + "clients": { + "grpc": { + "libraryClient": "VideoStitcherServiceClient", + "rpcs": { + "CreateCdnKey": { + "methods": [ + "create_cdn_key" + ] + }, + "CreateLiveConfig": { + "methods": [ + "create_live_config" + ] + }, + "CreateLiveSession": { + "methods": [ + "create_live_session" + ] + }, + "CreateSlate": { + "methods": [ + "create_slate" + ] + }, + "CreateVodConfig": { + "methods": [ + "create_vod_config" + ] + }, + "CreateVodSession": { + "methods": [ + "create_vod_session" + ] + }, + "DeleteCdnKey": { + "methods": [ + "delete_cdn_key" + ] + }, + "DeleteLiveConfig": { + "methods": [ + "delete_live_config" + ] + }, + "DeleteSlate": { + "methods": [ + "delete_slate" + ] + }, + "DeleteVodConfig": { + "methods": [ + "delete_vod_config" + ] + }, + "GetCdnKey": { + "methods": [ + "get_cdn_key" + ] + }, + "GetLiveAdTagDetail": { + "methods": [ + "get_live_ad_tag_detail" + ] + }, + "GetLiveConfig": { + "methods": [ + "get_live_config" + ] + }, + "GetLiveSession": { + "methods": [ + "get_live_session" + ] + }, + "GetSlate": { + "methods": [ + "get_slate" + ] + }, + "GetVodAdTagDetail": { + "methods": [ + "get_vod_ad_tag_detail" + ] + }, + "GetVodConfig": { + "methods": [ + "get_vod_config" + ] + }, + "GetVodSession": { + "methods": [ + "get_vod_session" + ] + }, + "GetVodStitchDetail": { + "methods": [ + "get_vod_stitch_detail" + ] + }, + "ListCdnKeys": { + "methods": [ + "list_cdn_keys" + ] + }, + "ListLiveAdTagDetails": { + "methods": [ + "list_live_ad_tag_details" + ] + }, + "ListLiveConfigs": { + "methods": [ + "list_live_configs" + ] + }, + "ListSlates": { + "methods": [ + "list_slates" + ] + }, + "ListVodAdTagDetails": { + "methods": [ + "list_vod_ad_tag_details" + ] + }, + "ListVodConfigs": { + "methods": [ + "list_vod_configs" + ] + }, + "ListVodStitchDetails": { + "methods": [ + "list_vod_stitch_details" + ] + }, + "UpdateCdnKey": { + "methods": [ + "update_cdn_key" + ] + }, + "UpdateLiveConfig": { + "methods": [ + "update_live_config" + ] + }, + "UpdateSlate": { + "methods": [ + "update_slate" + ] + }, + "UpdateVodConfig": { + "methods": [ + "update_vod_config" + ] + } + } + }, + "grpc-async": { + "libraryClient": "VideoStitcherServiceAsyncClient", + "rpcs": { + "CreateCdnKey": { + "methods": [ + "create_cdn_key" + ] + }, + "CreateLiveConfig": { + "methods": [ + "create_live_config" + ] + }, + "CreateLiveSession": { + "methods": [ + "create_live_session" + ] + }, + "CreateSlate": { + "methods": [ + "create_slate" + ] + }, + "CreateVodConfig": { + "methods": [ + "create_vod_config" + ] + }, + "CreateVodSession": { + "methods": [ + "create_vod_session" + ] + }, + "DeleteCdnKey": { + "methods": [ + "delete_cdn_key" + ] + }, + "DeleteLiveConfig": { + "methods": [ + "delete_live_config" + ] + }, + "DeleteSlate": { + "methods": [ + "delete_slate" + ] + }, + "DeleteVodConfig": { + "methods": [ + "delete_vod_config" + ] + }, + "GetCdnKey": { + "methods": [ + "get_cdn_key" + ] + }, + "GetLiveAdTagDetail": { + "methods": [ + "get_live_ad_tag_detail" + ] + }, + "GetLiveConfig": { + "methods": [ + "get_live_config" + ] + }, + "GetLiveSession": { + "methods": [ + "get_live_session" + ] + }, + "GetSlate": { + "methods": [ + "get_slate" + ] + }, + "GetVodAdTagDetail": { + "methods": [ + "get_vod_ad_tag_detail" + ] + }, + "GetVodConfig": { + "methods": [ + "get_vod_config" + ] + }, + "GetVodSession": { + "methods": [ + "get_vod_session" + ] + }, + "GetVodStitchDetail": { + "methods": [ + "get_vod_stitch_detail" + ] + }, + "ListCdnKeys": { + "methods": [ + "list_cdn_keys" + ] + }, + "ListLiveAdTagDetails": { + "methods": [ + "list_live_ad_tag_details" + ] + }, + "ListLiveConfigs": { + "methods": [ + "list_live_configs" + ] + }, + "ListSlates": { + "methods": [ + "list_slates" + ] + }, + "ListVodAdTagDetails": { + "methods": [ + "list_vod_ad_tag_details" + ] + }, + "ListVodConfigs": { + "methods": [ + "list_vod_configs" + ] + }, + "ListVodStitchDetails": { + "methods": [ + "list_vod_stitch_details" + ] + }, + "UpdateCdnKey": { + "methods": [ + "update_cdn_key" + ] + }, + "UpdateLiveConfig": { + "methods": [ + "update_live_config" + ] + }, + "UpdateSlate": { + "methods": [ + "update_slate" + ] + }, + "UpdateVodConfig": { + "methods": [ + "update_vod_config" + ] + } + } + }, + "rest": { + "libraryClient": "VideoStitcherServiceClient", + "rpcs": { + "CreateCdnKey": { + "methods": [ + "create_cdn_key" + ] + }, + "CreateLiveConfig": { + "methods": [ + "create_live_config" + ] + }, + "CreateLiveSession": { + "methods": [ + "create_live_session" + ] + }, + "CreateSlate": { + "methods": [ + "create_slate" + ] + }, + "CreateVodConfig": { + "methods": [ + "create_vod_config" + ] + }, + "CreateVodSession": { + "methods": [ + "create_vod_session" + ] + }, + "DeleteCdnKey": { + "methods": [ + "delete_cdn_key" + ] + }, + "DeleteLiveConfig": { + "methods": [ + "delete_live_config" + ] + }, + "DeleteSlate": { + "methods": [ + "delete_slate" + ] + }, + "DeleteVodConfig": { + "methods": [ + "delete_vod_config" + ] + }, + "GetCdnKey": { + "methods": [ + "get_cdn_key" + ] + }, + "GetLiveAdTagDetail": { + "methods": [ + "get_live_ad_tag_detail" + ] + }, + "GetLiveConfig": { + "methods": [ + "get_live_config" + ] + }, + "GetLiveSession": { + "methods": [ + "get_live_session" + ] + }, + "GetSlate": { + "methods": [ + "get_slate" + ] + }, + "GetVodAdTagDetail": { + "methods": [ + "get_vod_ad_tag_detail" + ] + }, + "GetVodConfig": { + "methods": [ + "get_vod_config" + ] + }, + "GetVodSession": { + "methods": [ + "get_vod_session" + ] + }, + "GetVodStitchDetail": { + "methods": [ + "get_vod_stitch_detail" + ] + }, + "ListCdnKeys": { + "methods": [ + "list_cdn_keys" + ] + }, + "ListLiveAdTagDetails": { + "methods": [ + "list_live_ad_tag_details" + ] + }, + "ListLiveConfigs": { + "methods": [ + "list_live_configs" + ] + }, + "ListSlates": { + "methods": [ + "list_slates" + ] + }, + "ListVodAdTagDetails": { + "methods": [ + "list_vod_ad_tag_details" + ] + }, + "ListVodConfigs": { + "methods": [ + "list_vod_configs" + ] + }, + "ListVodStitchDetails": { + "methods": [ + "list_vod_stitch_details" + ] + }, + "UpdateCdnKey": { + "methods": [ + "update_cdn_key" + ] + }, + "UpdateLiveConfig": { + "methods": [ + "update_live_config" + ] + }, + "UpdateSlate": { + "methods": [ + "update_slate" + ] + }, + "UpdateVodConfig": { + "methods": [ + "update_vod_config" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py new file mode 100644 index 000000000000..20a9cd975b02 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed new file mode 100644 index 000000000000..158ff5acbd28 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-video-stitcher package uses inline types. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py new file mode 100644 index 000000000000..cbf94b283c70 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py new file mode 100644 index 000000000000..5b1e06f53a81 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 VideoStitcherServiceClient +from .async_client import VideoStitcherServiceAsyncClient + +__all__ = ( + 'VideoStitcherServiceClient', + 'VideoStitcherServiceAsyncClient', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py new file mode 100644 index 000000000000..f9d204327157 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py @@ -0,0 +1,4240 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 logging as std_logging +from collections import OrderedDict +import re +from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union + +from google.cloud.video.stitcher_v1 import gapic_version as package_version + +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry_async as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore +import google.protobuf + + +try: + OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.video.stitcher_v1.services.video_stitcher_service import pagers +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import fetch_options +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from .transports.base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport +from .client import VideoStitcherServiceClient + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + +class VideoStitcherServiceAsyncClient: + """Video-On-Demand content stitching API allows you to insert + ads into (VoD) video on demand files. You will be able to render + custom scrubber bars with highlighted ads, enforce ad policies, + allow seamless playback and tracking on native players and + monetize content with any standard VMAP compliant ad server. + """ + + _client: VideoStitcherServiceClient + + # Copy defaults from the synchronous client for use here. + # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. + DEFAULT_ENDPOINT = VideoStitcherServiceClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT + _DEFAULT_ENDPOINT_TEMPLATE = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE + _DEFAULT_UNIVERSE = VideoStitcherServiceClient._DEFAULT_UNIVERSE + + cdn_key_path = staticmethod(VideoStitcherServiceClient.cdn_key_path) + parse_cdn_key_path = staticmethod(VideoStitcherServiceClient.parse_cdn_key_path) + live_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.live_ad_tag_detail_path) + parse_live_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.parse_live_ad_tag_detail_path) + live_config_path = staticmethod(VideoStitcherServiceClient.live_config_path) + parse_live_config_path = staticmethod(VideoStitcherServiceClient.parse_live_config_path) + live_session_path = staticmethod(VideoStitcherServiceClient.live_session_path) + parse_live_session_path = staticmethod(VideoStitcherServiceClient.parse_live_session_path) + slate_path = staticmethod(VideoStitcherServiceClient.slate_path) + parse_slate_path = staticmethod(VideoStitcherServiceClient.parse_slate_path) + vod_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.vod_ad_tag_detail_path) + parse_vod_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.parse_vod_ad_tag_detail_path) + vod_config_path = staticmethod(VideoStitcherServiceClient.vod_config_path) + parse_vod_config_path = staticmethod(VideoStitcherServiceClient.parse_vod_config_path) + vod_session_path = staticmethod(VideoStitcherServiceClient.vod_session_path) + parse_vod_session_path = staticmethod(VideoStitcherServiceClient.parse_vod_session_path) + vod_stitch_detail_path = staticmethod(VideoStitcherServiceClient.vod_stitch_detail_path) + parse_vod_stitch_detail_path = staticmethod(VideoStitcherServiceClient.parse_vod_stitch_detail_path) + common_billing_account_path = staticmethod(VideoStitcherServiceClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(VideoStitcherServiceClient.parse_common_billing_account_path) + common_folder_path = staticmethod(VideoStitcherServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(VideoStitcherServiceClient.parse_common_folder_path) + common_organization_path = staticmethod(VideoStitcherServiceClient.common_organization_path) + parse_common_organization_path = staticmethod(VideoStitcherServiceClient.parse_common_organization_path) + common_project_path = staticmethod(VideoStitcherServiceClient.common_project_path) + parse_common_project_path = staticmethod(VideoStitcherServiceClient.parse_common_project_path) + common_location_path = staticmethod(VideoStitcherServiceClient.common_location_path) + parse_common_location_path = staticmethod(VideoStitcherServiceClient.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: + VideoStitcherServiceAsyncClient: The constructed client. + """ + return VideoStitcherServiceClient.from_service_account_info.__func__(VideoStitcherServiceAsyncClient, 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: + VideoStitcherServiceAsyncClient: The constructed client. + """ + return VideoStitcherServiceClient.from_service_account_file.__func__(VideoStitcherServiceAsyncClient, 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 VideoStitcherServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> VideoStitcherServiceTransport: + """Returns the transport used by the client instance. + + Returns: + VideoStitcherServiceTransport: The transport used by the client instance. + """ + return self._client.transport + + @property + def api_endpoint(self): + """Return the API endpoint used by the client instance. + + Returns: + str: The API endpoint used by the client instance. + """ + return self._client._api_endpoint + + @property + def universe_domain(self) -> str: + """Return the universe domain used by the client instance. + + Returns: + str: The universe domain used + by the client instance. + """ + return self._client._universe_domain + + get_transport_class = VideoStitcherServiceClient.get_transport_class + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[Union[str, VideoStitcherServiceTransport, Callable[..., VideoStitcherServiceTransport]]] = "grpc_asyncio", + client_options: Optional[ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the video stitcher service async 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 (Optional[Union[str,VideoStitcherServiceTransport,Callable[..., VideoStitcherServiceTransport]]]): + The transport to use, or a Callable that constructs and returns a new transport to use. + If a Callable is given, it will be called with the same set of initialization + arguments as used in the VideoStitcherServiceTransport constructor. + 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. + + 1. The ``api_endpoint`` property can be used to override the + default endpoint provided by the client when ``transport`` is + not explicitly provided. Only if this property is not set and + ``transport`` was not explicitly provided, the endpoint is + determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment + variable, which have one of the following values: + "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). + + 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide a client certificate for mTLS 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. + + 3. The ``universe_domain`` property can be used to override the + default "googleapis.com" universe. Note that ``api_endpoint`` + property still takes precedence; and ``universe_domain`` is + currently not supported for mTLS. + + 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. + """ + self._client = VideoStitcherServiceClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient`.", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "universeDomain": getattr(self._client._transport._credentials, "universe_domain", ""), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), + } if hasattr(self._client._transport, "_credentials") else { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "credentialsType": None, + } + ) + + async def create_cdn_key(self, + request: Optional[Union[video_stitcher_service.CreateCdnKeyRequest, dict]] = None, + *, + parent: Optional[str] = None, + cdn_key: Optional[cdn_keys.CdnKey] = None, + cdn_key_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a new CDN key. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_create_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateCdnKeyRequest( + parent="parent_value", + cdn_key_id="cdn_key_id_value", + ) + + # Make the request + operation = client.create_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest, dict]]): + The request object. Request message for + VideoStitcherService.createCdnKey. + parent (:class:`str`): + Required. The project in which the CDN key should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + cdn_key (:class:`google.cloud.video.stitcher_v1.types.CdnKey`): + Required. The CDN key resource to + create. + + This corresponds to the ``cdn_key`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + cdn_key_id (:class:`str`): + Required. The ID to use for the CDN + key, which will become the final + component of the CDN key's resource + name. + + This value should conform to RFC-1034, + which restricts to lower-case letters, + numbers, and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``cdn_key_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher + to sign URIs for fetching video manifests and signing + media segments for playback. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, cdn_key, cdn_key_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateCdnKeyRequest): + request = video_stitcher_service.CreateCdnKeyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if cdn_key is not None: + request.cdn_key = cdn_key + if cdn_key_id is not None: + request.cdn_key_id = cdn_key_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.create_cdn_key] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + cdn_keys.CdnKey, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_cdn_keys(self, + request: Optional[Union[video_stitcher_service.ListCdnKeysRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListCdnKeysAsyncPager: + r"""Lists all CDN keys in the specified project and + 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.video import stitcher_v1 + + async def sample_list_cdn_keys(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListCdnKeysRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_cdn_keys(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.ListCdnKeysRequest, dict]]): + The request object. Request message for + VideoStitcherService.listCdnKeys. + parent (:class:`str`): + Required. The project that contains the list of CDN + keys, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager: + Response message for + VideoStitcher.ListCdnKeys. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListCdnKeysRequest): + request = video_stitcher_service.ListCdnKeysRequest(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._client._transport._wrapped_methods[self._client._transport.list_cdn_keys] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListCdnKeysAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_cdn_key(self, + request: Optional[Union[video_stitcher_service.GetCdnKeyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> cdn_keys.CdnKey: + r"""Returns the specified CDN key. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_get_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetCdnKeyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_cdn_key(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetCdnKeyRequest, dict]]): + The request object. Request message for + VideoStitcherService.getCdnKey. + name (:class:`str`): + Required. The name of the CDN key to be retrieved, in + the form of + ``projects/{project}/locations/{location}/cdnKeys/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.CdnKey: + Configuration for a CDN key. Used by + the Video Stitcher to sign URIs for + fetching video manifests and signing + media segments for playback. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetCdnKeyRequest): + request = video_stitcher_service.GetCdnKeyRequest(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._client._transport._wrapped_methods[self._client._transport.get_cdn_key] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_cdn_key(self, + request: Optional[Union[video_stitcher_service.DeleteCdnKeyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes the specified CDN key. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_delete_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteCdnKeyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest, dict]]): + The request object. Request message for + VideoStitcherService.deleteCdnKey. + name (:class:`str`): + Required. The name of the CDN key to be deleted, in the + form of + ``projects/{project_number}/locations/{location}/cdnKeys/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteCdnKeyRequest): + request = video_stitcher_service.DeleteCdnKeyRequest(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._client._transport._wrapped_methods[self._client._transport.delete_cdn_key] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_cdn_key(self, + request: Optional[Union[video_stitcher_service.UpdateCdnKeyRequest, dict]] = None, + *, + cdn_key: Optional[cdn_keys.CdnKey] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the specified CDN key. Only update fields + specified in the call method body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_update_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateCdnKeyRequest( + ) + + # Make the request + operation = client.update_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest, dict]]): + The request object. Request message for + VideoStitcherService.updateCdnKey. + cdn_key (:class:`google.cloud.video.stitcher_v1.types.CdnKey`): + Required. The CDN key resource which + replaces the resource on the server. + + This corresponds to the ``cdn_key`` 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 update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher + to sign URIs for fetching video manifests and signing + media segments for playback. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [cdn_key, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateCdnKeyRequest): + request = video_stitcher_service.UpdateCdnKeyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if cdn_key is not None: + request.cdn_key = cdn_key + 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._client._transport._wrapped_methods[self._client._transport.update_cdn_key] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("cdn_key.name", request.cdn_key.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + cdn_keys.CdnKey, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_vod_session(self, + request: Optional[Union[video_stitcher_service.CreateVodSessionRequest, dict]] = None, + *, + parent: Optional[str] = None, + vod_session: Optional[sessions.VodSession] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.VodSession: + r"""Creates a client side playback VOD session and + returns the full tracking and playback metadata of the + 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.video import stitcher_v1 + + async def sample_create_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + vod_session = stitcher_v1.VodSession() + vod_session.ad_tracking = "SERVER" + + request = stitcher_v1.CreateVodSessionRequest( + parent="parent_value", + vod_session=vod_session, + ) + + # Make the request + response = await client.create_vod_session(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateVodSessionRequest, dict]]): + The request object. Request message for + VideoStitcherService.createVodSession + parent (:class:`str`): + Required. The project and location in which the VOD + session should be created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vod_session (:class:`google.cloud.video.stitcher_v1.types.VodSession`): + Required. Parameters for creating a + session. + + This corresponds to the ``vod_session`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, vod_session] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateVodSessionRequest): + request = video_stitcher_service.CreateVodSessionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if vod_session is not None: + request.vod_session = vod_session + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.create_vod_session] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_vod_session(self, + request: Optional[Union[video_stitcher_service.GetVodSessionRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.VodSession: + r"""Returns the full tracking, playback metadata, and + relevant ad-ops logs for the specified VOD 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.video import stitcher_v1 + + async def sample_get_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodSessionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_session(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodSessionRequest, dict]]): + The request object. Request message for + VideoStitcherService.getVodSession + name (:class:`str`): + Required. The name of the VOD session to be retrieved, + in the form of + ``projects/{project_number}/locations/{location}/vodSessions/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodSessionRequest): + request = video_stitcher_service.GetVodSessionRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_session] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_vod_stitch_details(self, + request: Optional[Union[video_stitcher_service.ListVodStitchDetailsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVodStitchDetailsAsyncPager: + r"""Returns a list of detailed stitching information of + the specified VOD 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.video import stitcher_v1 + + async def sample_list_vod_stitch_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodStitchDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_stitch_details(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest, dict]]): + The request object. Request message for + VideoStitcherService.listVodStitchDetails. + parent (:class:`str`): + Required. The VOD session where the stitch details + belong to, in the form of + ``projects/{project}/locations/{location}/vodSessions/{id}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager: + Response message for + VideoStitcherService.listVodStitchDetails. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListVodStitchDetailsRequest): + request = video_stitcher_service.ListVodStitchDetailsRequest(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._client._transport._wrapped_methods[self._client._transport.list_vod_stitch_details] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListVodStitchDetailsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_vod_stitch_detail(self, + request: Optional[Union[video_stitcher_service.GetVodStitchDetailRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> stitch_details.VodStitchDetail: + r"""Returns the specified stitching information for the + specified VOD 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.video import stitcher_v1 + + async def sample_get_vod_stitch_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodStitchDetailRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_stitch_detail(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest, dict]]): + The request object. Request message for + VideoStitcherService.getVodStitchDetail. + name (:class:`str`): + Required. The name of the stitch detail in the specified + VOD session, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodStitchDetail: + Information related to the + interstitial of a VOD session. This + resource is only available for VOD + sessions that do not implement Google Ad + Manager ad insertion. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodStitchDetailRequest): + request = video_stitcher_service.GetVodStitchDetailRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_stitch_detail] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_vod_ad_tag_details(self, + request: Optional[Union[video_stitcher_service.ListVodAdTagDetailsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVodAdTagDetailsAsyncPager: + r"""Return the list of ad tag details for the specified + VOD 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.video import stitcher_v1 + + async def sample_list_vod_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_ad_tag_details(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest, dict]]): + The request object. Request message for + VideoStitcherService.listVodAdTagDetails. + parent (:class:`str`): + Required. The VOD session which the ad tag details + belong to, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager: + Response message for + VideoStitcherService.listVodAdTagDetails. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListVodAdTagDetailsRequest): + request = video_stitcher_service.ListVodAdTagDetailsRequest(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._client._transport._wrapped_methods[self._client._transport.list_vod_ad_tag_details] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListVodAdTagDetailsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_vod_ad_tag_detail(self, + request: Optional[Union[video_stitcher_service.GetVodAdTagDetailRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> ad_tag_details.VodAdTagDetail: + r"""Returns the specified ad tag detail for the specified + VOD 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.video import stitcher_v1 + + async def sample_get_vod_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_ad_tag_detail(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest, dict]]): + The request object. Request message for + VideoStitcherService.getVodAdTagDetail + name (:class:`str`): + Required. The name of the ad tag detail for the + specified VOD session, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{vod_ad_tag_detail}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for VOD sessions that do not + implement Google Ad Manager ad + insertion. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodAdTagDetailRequest): + request = video_stitcher_service.GetVodAdTagDetailRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_ad_tag_detail] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_live_ad_tag_details(self, + request: Optional[Union[video_stitcher_service.ListLiveAdTagDetailsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListLiveAdTagDetailsAsyncPager: + r"""Return the list of ad tag details for the specified + live 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.video import stitcher_v1 + + async def sample_list_live_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_ad_tag_details(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest, dict]]): + The request object. Request message for + VideoStitcherService.listLiveAdTagDetails. + parent (:class:`str`): + Required. The resource parent in the form of + ``projects/{project}/locations/{location}/liveSessions/{live_session}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager: + Response message for + VideoStitcherService.listLiveAdTagDetails. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListLiveAdTagDetailsRequest): + request = video_stitcher_service.ListLiveAdTagDetailsRequest(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._client._transport._wrapped_methods[self._client._transport.list_live_ad_tag_details] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListLiveAdTagDetailsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_live_ad_tag_detail(self, + request: Optional[Union[video_stitcher_service.GetLiveAdTagDetailRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> ad_tag_details.LiveAdTagDetail: + r"""Returns the specified ad tag detail for the specified + live 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.video import stitcher_v1 + + async def sample_get_live_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = await client.get_live_ad_tag_detail(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest, dict]]): + The request object. Request message for + VideoStitcherService.getLiveAdTagDetail + name (:class:`str`): + Required. The resource name in the form of + ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for live sessions that do not + implement Google Ad Manager ad + insertion. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetLiveAdTagDetailRequest): + request = video_stitcher_service.GetLiveAdTagDetailRequest(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._client._transport._wrapped_methods[self._client._transport.get_live_ad_tag_detail] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_slate(self, + request: Optional[Union[video_stitcher_service.CreateSlateRequest, dict]] = None, + *, + parent: Optional[str] = None, + slate: Optional[slates.Slate] = None, + slate_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Creates a slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_create_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateSlateRequest( + parent="parent_value", + slate_id="slate_id_value", + ) + + # Make the request + operation = client.create_slate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateSlateRequest, dict]]): + The request object. Request message for + VideoStitcherService.createSlate. + parent (:class:`str`): + Required. The project in which the slate should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + slate (:class:`google.cloud.video.stitcher_v1.types.Slate`): + Required. The slate to create. + This corresponds to the ``slate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + slate_id (:class:`str`): + Required. The unique identifier for + the slate. This value should conform to + RFC-1034, which restricts to lower-case + letters, numbers, and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``slate_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.Slate` + Slate object + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, slate, slate_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateSlateRequest): + request = video_stitcher_service.CreateSlateRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if slate is not None: + request.slate = slate + if slate_id is not None: + request.slate_id = slate_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.create_slate] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + slates.Slate, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_slates(self, + request: Optional[Union[video_stitcher_service.ListSlatesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListSlatesAsyncPager: + r"""Lists all slates in the specified project and + 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.video import stitcher_v1 + + async def sample_list_slates(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListSlatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_slates(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.ListSlatesRequest, dict]]): + The request object. Request message for + VideoStitcherService.listSlates. + parent (:class:`str`): + Required. The project to list slates, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager: + Response message for + VideoStitcherService.listSlates. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListSlatesRequest): + request = video_stitcher_service.ListSlatesRequest(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._client._transport._wrapped_methods[self._client._transport.list_slates] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListSlatesAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_slate(self, + request: Optional[Union[video_stitcher_service.GetSlateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> slates.Slate: + r"""Returns the specified slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_get_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetSlateRequest( + name="name_value", + ) + + # Make the request + response = await client.get_slate(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetSlateRequest, dict]]): + The request object. Request message for + VideoStitcherService.getSlate. + name (:class:`str`): + Required. The name of the slate to be retrieved, of the + slate, in the form of + ``projects/{project_number}/locations/{location}/slates/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.Slate: + Slate object + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetSlateRequest): + request = video_stitcher_service.GetSlateRequest(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._client._transport._wrapped_methods[self._client._transport.get_slate] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_slate(self, + request: Optional[Union[video_stitcher_service.UpdateSlateRequest, dict]] = None, + *, + slate: Optional[slates.Slate] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the specified slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_update_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateSlateRequest( + ) + + # Make the request + operation = client.update_slate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateSlateRequest, dict]]): + The request object. Request message for + VideoStitcherService.updateSlate. + slate (:class:`google.cloud.video.stitcher_v1.types.Slate`): + Required. The resource with updated + fields. + + This corresponds to the ``slate`` 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 update mask which + specifies fields which should 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_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.Slate` + Slate object + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [slate, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateSlateRequest): + request = video_stitcher_service.UpdateSlateRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if slate is not None: + request.slate = slate + 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._client._transport._wrapped_methods[self._client._transport.update_slate] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("slate.name", request.slate.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + slates.Slate, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def delete_slate(self, + request: Optional[Union[video_stitcher_service.DeleteSlateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes the specified slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_delete_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteSlateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_slate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteSlateRequest, dict]]): + The request object. Request message for + VideoStitcherService.deleteSlate. + name (:class:`str`): + Required. The name of the slate to be deleted, in the + form of + ``projects/{project_number}/locations/{location}/slates/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteSlateRequest): + request = video_stitcher_service.DeleteSlateRequest(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._client._transport._wrapped_methods[self._client._transport.delete_slate] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_live_session(self, + request: Optional[Union[video_stitcher_service.CreateLiveSessionRequest, dict]] = None, + *, + parent: Optional[str] = None, + live_session: Optional[sessions.LiveSession] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.LiveSession: + r"""Creates a new live 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.video import stitcher_v1 + + async def sample_create_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + live_session = stitcher_v1.LiveSession() + live_session.live_config = "live_config_value" + + request = stitcher_v1.CreateLiveSessionRequest( + parent="parent_value", + live_session=live_session, + ) + + # Make the request + response = await client.create_live_session(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest, dict]]): + The request object. Request message for + VideoStitcherService.createLiveSession. + parent (:class:`str`): + Required. The project and location in which the live + session should be created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + live_session (:class:`google.cloud.video.stitcher_v1.types.LiveSession`): + Required. Parameters for creating a + live session. + + This corresponds to the ``live_session`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, live_session] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateLiveSessionRequest): + request = video_stitcher_service.CreateLiveSessionRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if live_session is not None: + request.live_session = live_session + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.create_live_session] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_live_session(self, + request: Optional[Union[video_stitcher_service.GetLiveSessionRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.LiveSession: + r"""Returns the details for the specified live 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.video import stitcher_v1 + + async def sample_get_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveSessionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_live_session(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetLiveSessionRequest, dict]]): + The request object. Request message for + VideoStitcherService.getSession. + name (:class:`str`): + Required. The name of the live session, in the form of + ``projects/{project_number}/locations/{location}/liveSessions/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetLiveSessionRequest): + request = video_stitcher_service.GetLiveSessionRequest(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._client._transport._wrapped_methods[self._client._transport.get_live_session] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def create_live_config(self, + request: Optional[Union[video_stitcher_service.CreateLiveConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + live_config: Optional[live_configs.LiveConfig] = None, + live_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Registers the live config with the provided unique ID + in the specified region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_create_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.CreateLiveConfigRequest( + parent="parent_value", + live_config_id="live_config_id_value", + live_config=live_config, + ) + + # Make the request + operation = client.create_live_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.createLiveConfig + parent (:class:`str`): + Required. The project in which the live config should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + live_config (:class:`google.cloud.video.stitcher_v1.types.LiveConfig`): + Required. The live config resource to + create. + + This corresponds to the ``live_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + live_config_id (:class:`str`): + Required. The unique identifier ID to + use for the live config. + + This corresponds to the ``live_config_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.LiveConfig` + Metadata for used to register live configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, live_config, live_config_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateLiveConfigRequest): + request = video_stitcher_service.CreateLiveConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if live_config is not None: + request.live_config = live_config + if live_config_id is not None: + request.live_config_id = live_config_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.create_live_config] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + live_configs.LiveConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_live_configs(self, + request: Optional[Union[video_stitcher_service.ListLiveConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListLiveConfigsAsyncPager: + r"""Lists all live configs managed by the Video Stitcher + that belong to the specified project and region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_list_live_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest, dict]]): + The request object. Request message for + VideoStitcherService.listLiveConfig. + parent (:class:`str`): + Required. The project that contains the list of live + configs, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager: + Response message for + VideoStitcher.ListLiveConfig. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListLiveConfigsRequest): + request = video_stitcher_service.ListLiveConfigsRequest(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._client._transport._wrapped_methods[self._client._transport.list_live_configs] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListLiveConfigsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_live_config(self, + request: Optional[Union[video_stitcher_service.GetLiveConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> live_configs.LiveConfig: + r"""Returns the specified live config managed by the + Video Stitcher service. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_get_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_live_config(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetLiveConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.getLiveConfig. + name (:class:`str`): + Required. The name of the live config to be retrieved, + in the form of + ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveConfig: + Metadata for used to register live + configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetLiveConfigRequest): + request = video_stitcher_service.GetLiveConfigRequest(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._client._transport._wrapped_methods[self._client._transport.get_live_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_live_config(self, + request: Optional[Union[video_stitcher_service.DeleteLiveConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes the specified live config. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_delete_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteLiveConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_live_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.deleteLiveConfig. + name (:class:`str`): + Required. The name of the live config to be deleted, in + the form of + ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteLiveConfigRequest): + request = video_stitcher_service.DeleteLiveConfigRequest(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._client._transport._wrapped_methods[self._client._transport.delete_live_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_live_config(self, + request: Optional[Union[video_stitcher_service.UpdateLiveConfigRequest, dict]] = None, + *, + live_config: Optional[live_configs.LiveConfig] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the specified LiveConfig. Only update fields + specified in the call method body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_update_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.UpdateLiveConfigRequest( + live_config=live_config, + ) + + # Make the request + operation = client.update_live_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.updateLiveConfig. + live_config (:class:`google.cloud.video.stitcher_v1.types.LiveConfig`): + Required. The LiveConfig resource + which replaces the resource on the + server. + + This corresponds to the ``live_config`` 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 update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.LiveConfig` + Metadata for used to register live configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [live_config, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateLiveConfigRequest): + request = video_stitcher_service.UpdateLiveConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if live_config is not None: + request.live_config = live_config + 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._client._transport._wrapped_methods[self._client._transport.update_live_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("live_config.name", request.live_config.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + live_configs.LiveConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def create_vod_config(self, + request: Optional[Union[video_stitcher_service.CreateVodConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + vod_config: Optional[vod_configs.VodConfig] = None, + vod_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Registers the VOD config with the provided unique ID + in the specified region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_create_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.CreateVodConfigRequest( + parent="parent_value", + vod_config_id="vod_config_id_value", + vod_config=vod_config, + ) + + # Make the request + operation = client.create_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateVodConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.createVodConfig + parent (:class:`str`): + Required. The project in which the VOD config should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vod_config (:class:`google.cloud.video.stitcher_v1.types.VodConfig`): + Required. The VOD config resource to + create. + + This corresponds to the ``vod_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vod_config_id (:class:`str`): + Required. The unique identifier ID to + use for the VOD config. + + This corresponds to the ``vod_config_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.VodConfig` + Metadata used to register VOD configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, vod_config, vod_config_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateVodConfigRequest): + request = video_stitcher_service.CreateVodConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if vod_config is not None: + request.vod_config = vod_config + if vod_config_id is not None: + request.vod_config_id = vod_config_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._client._transport._wrapped_methods[self._client._transport.create_vod_config] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + vod_configs.VodConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def list_vod_configs(self, + request: Optional[Union[video_stitcher_service.ListVodConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVodConfigsAsyncPager: + r"""Lists all VOD configs managed by the Video Stitcher + API that belong to the specified project and region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_list_vod_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.ListVodConfigsRequest, dict]]): + The request object. Request message for + VideoStitcherService.listVodConfig. + parent (:class:`str`): + Required. The project that contains the list of VOD + configs, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager: + Response message for + VideoStitcher.ListVodConfig. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListVodConfigsRequest): + request = video_stitcher_service.ListVodConfigsRequest(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._client._transport._wrapped_methods[self._client._transport.list_vod_configs] + + # 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), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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.ListVodConfigsAsyncPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_vod_config(self, + request: Optional[Union[video_stitcher_service.GetVodConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> vod_configs.VodConfig: + r"""Returns the specified VOD config managed by the Video + Stitcher API service. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_get_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_config(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.getVodConfig. + name (:class:`str`): + Required. The name of the VOD config to be retrieved, in + the form of + ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodConfig: + Metadata used to register VOD + configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodConfigRequest): + request = video_stitcher_service.GetVodConfigRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_vod_config(self, + request: Optional[Union[video_stitcher_service.DeleteVodConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Deletes the specified VOD config. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_delete_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteVodConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.deleteVodConfig. + name (:class:`str`): + Required. The name of the VOD config to be deleted, in + the form of + ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteVodConfigRequest): + request = video_stitcher_service.DeleteVodConfigRequest(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._client._transport._wrapped_methods[self._client._transport.delete_vod_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + async def update_vod_config(self, + request: Optional[Union[video_stitcher_service.UpdateVodConfigRequest, dict]] = None, + *, + vod_config: Optional[vod_configs.VodConfig] = 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, Union[str, bytes]]] = (), + ) -> operation_async.AsyncOperation: + r"""Updates the specified VOD config. Only update fields + specified in the call method body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + async def sample_update_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.UpdateVodConfigRequest( + vod_config=vod_config, + ) + + # Make the request + operation = client.update_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest, dict]]): + The request object. Request message for + VideoStitcherService.updateVodConfig. + vod_config (:class:`google.cloud.video.stitcher_v1.types.VodConfig`): + Required. The VOD config resource + which replaces the resource on the + server. + + This corresponds to the ``vod_config`` 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 update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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_async.AsyncRetry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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.video.stitcher_v1.types.VodConfig` + Metadata used to register VOD configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [vod_config, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError("If the `request` argument is set, then none of " + "the individual field arguments should be set.") + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateVodConfigRequest): + request = video_stitcher_service.UpdateVodConfigRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if vod_config is not None: + request.vod_config = vod_config + 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._client._transport._wrapped_methods[self._client._transport.update_vod_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("vod_config.name", request.vod_config.name), + )), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, + vod_configs.VodConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # 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, Union[str, bytes]]] = (), + ) -> 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_async.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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 = self.transport._wrapped_methods[self._client._transport.list_operations] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # 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, Union[str, bytes]]] = (), + ) -> 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_async.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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 = self.transport._wrapped_methods[self._client._transport.get_operation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + response = await rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + async def delete_operation( + self, + request: Optional[operations_pb2.DeleteOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> None: + r"""Deletes a long-running operation. + + This method indicates that the client is no longer interested + in the operation result. It does not cancel the operation. + If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.DeleteOperationRequest`): + The request object. Request message for + `DeleteOperation` method. + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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.DeleteOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self.transport._wrapped_methods[self._client._transport.delete_operation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + 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, Union[str, bytes]]] = (), + ) -> 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_async.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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 = self.transport._wrapped_methods[self._client._transport.cancel_operation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._client._validate_universe_domain() + + # Send the request. + await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + async def __aenter__(self) -> "VideoStitcherServiceAsyncClient": + 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__) + +if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER + DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ + + +__all__ = ( + "VideoStitcherServiceAsyncClient", +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py new file mode 100644 index 000000000000..5410b0e72088 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py @@ -0,0 +1,4651 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 http import HTTPStatus +import json +import logging as std_logging +import os +import re +from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast +import warnings + +from google.cloud.video.stitcher_v1 import gapic_version as package_version + +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore +import google.protobuf + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object, None] # type: ignore + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + +from google.api_core import operation # type: ignore +from google.api_core import operation_async # type: ignore +from google.cloud.video.stitcher_v1.services.video_stitcher_service import pagers +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import fetch_options +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from .transports.base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import VideoStitcherServiceGrpcTransport +from .transports.grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport +from .transports.rest import VideoStitcherServiceRestTransport + + +class VideoStitcherServiceClientMeta(type): + """Metaclass for the VideoStitcherService 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[VideoStitcherServiceTransport]] + _transport_registry["grpc"] = VideoStitcherServiceGrpcTransport + _transport_registry["grpc_asyncio"] = VideoStitcherServiceGrpcAsyncIOTransport + _transport_registry["rest"] = VideoStitcherServiceRestTransport + + def get_transport_class(cls, + label: Optional[str] = None, + ) -> Type[VideoStitcherServiceTransport]: + """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 VideoStitcherServiceClient(metaclass=VideoStitcherServiceClientMeta): + """Video-On-Demand content stitching API allows you to insert + ads into (VoD) video on demand files. You will be able to render + custom scrubber bars with highlighted ads, enforce ad policies, + allow seamless playback and tracking on native players and + monetize content with any standard VMAP compliant ad server. + """ + + @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") + + # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. + DEFAULT_ENDPOINT = "videostitcher.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + _DEFAULT_ENDPOINT_TEMPLATE = "videostitcher.{UNIVERSE_DOMAIN}" + _DEFAULT_UNIVERSE = "googleapis.com" + + @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: + VideoStitcherServiceClient: 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: + VideoStitcherServiceClient: 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) -> VideoStitcherServiceTransport: + """Returns the transport used by the client instance. + + Returns: + VideoStitcherServiceTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def cdn_key_path(project: str,location: str,cdn_key: str,) -> str: + """Returns a fully-qualified cdn_key string.""" + return "projects/{project}/locations/{location}/cdnKeys/{cdn_key}".format(project=project, location=location, cdn_key=cdn_key, ) + + @staticmethod + def parse_cdn_key_path(path: str) -> Dict[str,str]: + """Parses a cdn_key path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/cdnKeys/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def live_ad_tag_detail_path(project: str,location: str,live_session: str,live_ad_tag_detail: str,) -> str: + """Returns a fully-qualified live_ad_tag_detail string.""" + return "projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}".format(project=project, location=location, live_session=live_session, live_ad_tag_detail=live_ad_tag_detail, ) + + @staticmethod + def parse_live_ad_tag_detail_path(path: str) -> Dict[str,str]: + """Parses a live_ad_tag_detail path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/liveSessions/(?P.+?)/liveAdTagDetails/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def live_config_path(project: str,location: str,live_config: str,) -> str: + """Returns a fully-qualified live_config string.""" + return "projects/{project}/locations/{location}/liveConfigs/{live_config}".format(project=project, location=location, live_config=live_config, ) + + @staticmethod + def parse_live_config_path(path: str) -> Dict[str,str]: + """Parses a live_config path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/liveConfigs/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def live_session_path(project: str,location: str,live_session: str,) -> str: + """Returns a fully-qualified live_session string.""" + return "projects/{project}/locations/{location}/liveSessions/{live_session}".format(project=project, location=location, live_session=live_session, ) + + @staticmethod + def parse_live_session_path(path: str) -> Dict[str,str]: + """Parses a live_session path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/liveSessions/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def slate_path(project: str,location: str,slate: str,) -> str: + """Returns a fully-qualified slate string.""" + return "projects/{project}/locations/{location}/slates/{slate}".format(project=project, location=location, slate=slate, ) + + @staticmethod + def parse_slate_path(path: str) -> Dict[str,str]: + """Parses a slate path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/slates/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def vod_ad_tag_detail_path(project: str,location: str,vod_session: str,vod_ad_tag_detail: str,) -> str: + """Returns a fully-qualified vod_ad_tag_detail string.""" + return "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodAdTagDetails/{vod_ad_tag_detail}".format(project=project, location=location, vod_session=vod_session, vod_ad_tag_detail=vod_ad_tag_detail, ) + + @staticmethod + def parse_vod_ad_tag_detail_path(path: str) -> Dict[str,str]: + """Parses a vod_ad_tag_detail path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodSessions/(?P.+?)/vodAdTagDetails/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def vod_config_path(project: str,location: str,vod_config: str,) -> str: + """Returns a fully-qualified vod_config string.""" + return "projects/{project}/locations/{location}/vodConfigs/{vod_config}".format(project=project, location=location, vod_config=vod_config, ) + + @staticmethod + def parse_vod_config_path(path: str) -> Dict[str,str]: + """Parses a vod_config path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodConfigs/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def vod_session_path(project: str,location: str,vod_session: str,) -> str: + """Returns a fully-qualified vod_session string.""" + return "projects/{project}/locations/{location}/vodSessions/{vod_session}".format(project=project, location=location, vod_session=vod_session, ) + + @staticmethod + def parse_vod_session_path(path: str) -> Dict[str,str]: + """Parses a vod_session path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodSessions/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def vod_stitch_detail_path(project: str,location: str,vod_session: str,vod_stitch_detail: str,) -> str: + """Returns a fully-qualified vod_stitch_detail string.""" + return "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodStitchDetails/{vod_stitch_detail}".format(project=project, location=location, vod_session=vod_session, vod_stitch_detail=vod_stitch_detail, ) + + @staticmethod + def parse_vod_stitch_detail_path(path: str) -> Dict[str,str]: + """Parses a vod_stitch_detail path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodSessions/(?P.+?)/vodStitchDetails/(?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): + """Deprecated. 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. + """ + + warnings.warn("get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", + DeprecationWarning) + 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 + + @staticmethod + def _read_environment_variables(): + """Returns the environment variables used by the client. + + Returns: + Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, + GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. + + Raises: + ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not + any of ["true", "false"]. + google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT + is not any of ["auto", "never", "always"]. + """ + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false").lower() + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() + universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") + 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`") + return use_client_cert == "true", use_mtls_endpoint, universe_domain_env + + @staticmethod + def _get_client_cert_source(provided_cert_source, use_cert_flag): + """Return the client cert source to be used by the client. + + Args: + provided_cert_source (bytes): The client certificate source provided. + use_cert_flag (bool): A flag indicating whether to use the client certificate. + + Returns: + bytes or None: The client cert source to be used by the client. + """ + client_cert_source = None + if use_cert_flag: + if provided_cert_source: + client_cert_source = provided_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + return client_cert_source + + @staticmethod + def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint): + """Return the API endpoint used by the client. + + Args: + api_override (str): The API endpoint override. If specified, this is always + the return value of this function and the other arguments are not used. + client_cert_source (bytes): The client certificate source used by the client. + universe_domain (str): The universe domain used by the client. + use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. + Possible values are "always", "auto", or "never". + + Returns: + str: The API endpoint to be used by the client. + """ + if api_override is not None: + api_endpoint = api_override + elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): + _default_universe = VideoStitcherServiceClient._DEFAULT_UNIVERSE + if universe_domain != _default_universe: + raise MutualTLSChannelError(f"mTLS is not supported in any universe other than {_default_universe}.") + api_endpoint = VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=universe_domain) + return api_endpoint + + @staticmethod + def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str: + """Return the universe domain used by the client. + + Args: + client_universe_domain (Optional[str]): The universe domain configured via the client options. + universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. + + Returns: + str: The universe domain to be used by the client. + + Raises: + ValueError: If the universe domain is an empty string. + """ + universe_domain = VideoStitcherServiceClient._DEFAULT_UNIVERSE + if client_universe_domain is not None: + universe_domain = client_universe_domain + elif universe_domain_env is not None: + universe_domain = universe_domain_env + if len(universe_domain.strip()) == 0: + raise ValueError("Universe Domain cannot be an empty string.") + return universe_domain + + def _validate_universe_domain(self): + """Validates client's and credentials' universe domains are consistent. + + Returns: + bool: True iff the configured universe domain is valid. + + Raises: + ValueError: If the configured universe domain is not valid. + """ + + # NOTE (b/349488459): universe validation is disabled until further notice. + return True + + def _add_cred_info_for_auth_errors( + self, + error: core_exceptions.GoogleAPICallError + ) -> None: + """Adds credential info string to error details for 401/403/404 errors. + + Args: + error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info. + """ + if error.code not in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN, HTTPStatus.NOT_FOUND]: + return + + cred = self._transport._credentials + + # get_cred_info is only available in google-auth>=2.35.0 + if not hasattr(cred, "get_cred_info"): + return + + # ignore the type check since pypy test fails when get_cred_info + # is not available + cred_info = cred.get_cred_info() # type: ignore + if cred_info and hasattr(error._details, "append"): + error._details.append(json.dumps(cred_info)) + + @property + def api_endpoint(self): + """Return the API endpoint used by the client instance. + + Returns: + str: The API endpoint used by the client instance. + """ + return self._api_endpoint + + @property + def universe_domain(self) -> str: + """Return the universe domain used by the client instance. + + Returns: + str: The universe domain used by the client instance. + """ + return self._universe_domain + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[Union[str, VideoStitcherServiceTransport, Callable[..., VideoStitcherServiceTransport]]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the video stitcher 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 (Optional[Union[str,VideoStitcherServiceTransport,Callable[..., VideoStitcherServiceTransport]]]): + The transport to use, or a Callable that constructs and returns a new transport. + If a Callable is given, it will be called with the same set of initialization + arguments as used in the VideoStitcherServiceTransport constructor. + 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. + + 1. The ``api_endpoint`` property can be used to override the + default endpoint provided by the client when ``transport`` is + not explicitly provided. Only if this property is not set and + ``transport`` was not explicitly provided, the endpoint is + determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment + variable, which have one of the following values: + "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). + + 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide a client certificate for mTLS 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. + + 3. The ``universe_domain`` property can be used to override the + default "googleapis.com" universe. Note that the ``api_endpoint`` + property still takes precedence; and ``universe_domain`` is + currently not supported for mTLS. + + 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. + """ + self._client_options = client_options + if isinstance(self._client_options, dict): + self._client_options = client_options_lib.from_dict(self._client_options) + if self._client_options is None: + self._client_options = client_options_lib.ClientOptions() + self._client_options = cast(client_options_lib.ClientOptions, self._client_options) + + universe_domain_opt = getattr(self._client_options, 'universe_domain', None) + + self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = VideoStitcherServiceClient._read_environment_variables() + self._client_cert_source = VideoStitcherServiceClient._get_client_cert_source(self._client_options.client_cert_source, self._use_client_cert) + self._universe_domain = VideoStitcherServiceClient._get_universe_domain(universe_domain_opt, self._universe_domain_env) + self._api_endpoint = None # updated below, depending on `transport` + + # Initialize the universe domain validation. + self._is_universe_domain_valid = False + + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + + api_key_value = getattr(self._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. + transport_provided = isinstance(transport, VideoStitcherServiceTransport) + if transport_provided: + # transport is a VideoStitcherServiceTransport instance. + if credentials or self._client_options.credentials_file or api_key_value: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if self._client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = cast(VideoStitcherServiceTransport, transport) + self._api_endpoint = self._transport.host + + self._api_endpoint = (self._api_endpoint or + VideoStitcherServiceClient._get_api_endpoint( + self._client_options.api_endpoint, + self._client_cert_source, + self._universe_domain, + self._use_mtls_endpoint)) + + if not transport_provided: + 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_init: Union[Type[VideoStitcherServiceTransport], Callable[..., VideoStitcherServiceTransport]] = ( + VideoStitcherServiceClient.get_transport_class(transport) + if isinstance(transport, str) or transport is None + else cast(Callable[..., VideoStitcherServiceTransport], transport) + ) + # initialize with the provided callable or the passed in class + self._transport = transport_init( + credentials=credentials, + credentials_file=self._client_options.credentials_file, + host=self._api_endpoint, + scopes=self._client_options.scopes, + client_cert_source_for_mtls=self._client_cert_source, + quota_project_id=self._client_options.quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + api_audience=self._client_options.api_audience, + ) + + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.video.stitcher_v1.VideoStitcherServiceClient`.", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "universeDomain": getattr(self._transport._credentials, "universe_domain", ""), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), + } if hasattr(self._transport, "_credentials") else { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "credentialsType": None, + } + ) + + def create_cdn_key(self, + request: Optional[Union[video_stitcher_service.CreateCdnKeyRequest, dict]] = None, + *, + parent: Optional[str] = None, + cdn_key: Optional[cdn_keys.CdnKey] = None, + cdn_key_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a new CDN key. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_create_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateCdnKeyRequest( + parent="parent_value", + cdn_key_id="cdn_key_id_value", + ) + + # Make the request + operation = client.create_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest, dict]): + The request object. Request message for + VideoStitcherService.createCdnKey. + parent (str): + Required. The project in which the CDN key should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): + Required. The CDN key resource to + create. + + This corresponds to the ``cdn_key`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + cdn_key_id (str): + Required. The ID to use for the CDN + key, which will become the final + component of the CDN key's resource + name. + + This value should conform to RFC-1034, + which restricts to lower-case letters, + numbers, and hyphen, with the first + character a letter, the last a letter or + a number, and a 63 character maximum. + + This corresponds to the ``cdn_key_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher + to sign URIs for fetching video manifests and signing + media segments for playback. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, cdn_key, cdn_key_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateCdnKeyRequest): + request = video_stitcher_service.CreateCdnKeyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if cdn_key is not None: + request.cdn_key = cdn_key + if cdn_key_id is not None: + request.cdn_key_id = cdn_key_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_cdn_key] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + cdn_keys.CdnKey, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_cdn_keys(self, + request: Optional[Union[video_stitcher_service.ListCdnKeysRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListCdnKeysPager: + r"""Lists all CDN keys in the specified project and + 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.video import stitcher_v1 + + def sample_list_cdn_keys(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListCdnKeysRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_cdn_keys(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.ListCdnKeysRequest, dict]): + The request object. Request message for + VideoStitcherService.listCdnKeys. + parent (str): + Required. The project that contains the list of CDN + keys, in the form of + ``projects/{project_number}/locations/{location}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager: + Response message for + VideoStitcher.ListCdnKeys. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListCdnKeysRequest): + request = video_stitcher_service.ListCdnKeysRequest(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_cdn_keys] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListCdnKeysPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_cdn_key(self, + request: Optional[Union[video_stitcher_service.GetCdnKeyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> cdn_keys.CdnKey: + r"""Returns the specified CDN key. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_get_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetCdnKeyRequest( + name="name_value", + ) + + # Make the request + response = client.get_cdn_key(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetCdnKeyRequest, dict]): + The request object. Request message for + VideoStitcherService.getCdnKey. + name (str): + Required. The name of the CDN key to be retrieved, in + the form of + ``projects/{project}/locations/{location}/cdnKeys/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.CdnKey: + Configuration for a CDN key. Used by + the Video Stitcher to sign URIs for + fetching video manifests and signing + media segments for playback. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetCdnKeyRequest): + request = video_stitcher_service.GetCdnKeyRequest(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_cdn_key] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_cdn_key(self, + request: Optional[Union[video_stitcher_service.DeleteCdnKeyRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes the specified CDN key. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_delete_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteCdnKeyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest, dict]): + The request object. Request message for + VideoStitcherService.deleteCdnKey. + name (str): + Required. The name of the CDN key to be deleted, in the + form of + ``projects/{project_number}/locations/{location}/cdnKeys/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteCdnKeyRequest): + request = video_stitcher_service.DeleteCdnKeyRequest(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_cdn_key] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_cdn_key(self, + request: Optional[Union[video_stitcher_service.UpdateCdnKeyRequest, dict]] = None, + *, + cdn_key: Optional[cdn_keys.CdnKey] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the specified CDN key. Only update fields + specified in the call method body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_update_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateCdnKeyRequest( + ) + + # Make the request + operation = client.update_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest, dict]): + The request object. Request message for + VideoStitcherService.updateCdnKey. + cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): + Required. The CDN key resource which + replaces the resource on the server. + + This corresponds to the ``cdn_key`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be :class:`google.cloud.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher + to sign URIs for fetching video manifests and signing + media segments for playback. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [cdn_key, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateCdnKeyRequest): + request = video_stitcher_service.UpdateCdnKeyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if cdn_key is not None: + request.cdn_key = cdn_key + 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_cdn_key] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("cdn_key.name", request.cdn_key.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + cdn_keys.CdnKey, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_vod_session(self, + request: Optional[Union[video_stitcher_service.CreateVodSessionRequest, dict]] = None, + *, + parent: Optional[str] = None, + vod_session: Optional[sessions.VodSession] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.VodSession: + r"""Creates a client side playback VOD session and + returns the full tracking and playback metadata of the + 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.video import stitcher_v1 + + def sample_create_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + vod_session = stitcher_v1.VodSession() + vod_session.ad_tracking = "SERVER" + + request = stitcher_v1.CreateVodSessionRequest( + parent="parent_value", + vod_session=vod_session, + ) + + # Make the request + response = client.create_vod_session(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.CreateVodSessionRequest, dict]): + The request object. Request message for + VideoStitcherService.createVodSession + parent (str): + Required. The project and location in which the VOD + session should be created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vod_session (google.cloud.video.stitcher_v1.types.VodSession): + Required. Parameters for creating a + session. + + This corresponds to the ``vod_session`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, vod_session] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateVodSessionRequest): + request = video_stitcher_service.CreateVodSessionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if vod_session is not None: + request.vod_session = vod_session + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_vod_session] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_vod_session(self, + request: Optional[Union[video_stitcher_service.GetVodSessionRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.VodSession: + r"""Returns the full tracking, playback metadata, and + relevant ad-ops logs for the specified VOD 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.video import stitcher_v1 + + def sample_get_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodSessionRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_session(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetVodSessionRequest, dict]): + The request object. Request message for + VideoStitcherService.getVodSession + name (str): + Required. The name of the VOD session to be retrieved, + in the form of + ``projects/{project_number}/locations/{location}/vodSessions/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodSessionRequest): + request = video_stitcher_service.GetVodSessionRequest(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_vod_session] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_vod_stitch_details(self, + request: Optional[Union[video_stitcher_service.ListVodStitchDetailsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVodStitchDetailsPager: + r"""Returns a list of detailed stitching information of + the specified VOD 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.video import stitcher_v1 + + def sample_list_vod_stitch_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodStitchDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_stitch_details(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest, dict]): + The request object. Request message for + VideoStitcherService.listVodStitchDetails. + parent (str): + Required. The VOD session where the stitch details + belong to, in the form of + ``projects/{project}/locations/{location}/vodSessions/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager: + Response message for + VideoStitcherService.listVodStitchDetails. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListVodStitchDetailsRequest): + request = video_stitcher_service.ListVodStitchDetailsRequest(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_vod_stitch_details] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListVodStitchDetailsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_vod_stitch_detail(self, + request: Optional[Union[video_stitcher_service.GetVodStitchDetailRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> stitch_details.VodStitchDetail: + r"""Returns the specified stitching information for the + specified VOD 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.video import stitcher_v1 + + def sample_get_vod_stitch_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodStitchDetailRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_stitch_detail(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest, dict]): + The request object. Request message for + VideoStitcherService.getVodStitchDetail. + name (str): + Required. The name of the stitch detail in the specified + VOD session, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodStitchDetail: + Information related to the + interstitial of a VOD session. This + resource is only available for VOD + sessions that do not implement Google Ad + Manager ad insertion. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodStitchDetailRequest): + request = video_stitcher_service.GetVodStitchDetailRequest(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_vod_stitch_detail] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_vod_ad_tag_details(self, + request: Optional[Union[video_stitcher_service.ListVodAdTagDetailsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVodAdTagDetailsPager: + r"""Return the list of ad tag details for the specified + VOD 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.video import stitcher_v1 + + def sample_list_vod_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_ad_tag_details(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest, dict]): + The request object. Request message for + VideoStitcherService.listVodAdTagDetails. + parent (str): + Required. The VOD session which the ad tag details + belong to, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager: + Response message for + VideoStitcherService.listVodAdTagDetails. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListVodAdTagDetailsRequest): + request = video_stitcher_service.ListVodAdTagDetailsRequest(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_vod_ad_tag_details] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListVodAdTagDetailsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_vod_ad_tag_detail(self, + request: Optional[Union[video_stitcher_service.GetVodAdTagDetailRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> ad_tag_details.VodAdTagDetail: + r"""Returns the specified ad tag detail for the specified + VOD 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.video import stitcher_v1 + + def sample_get_vod_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_ad_tag_detail(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest, dict]): + The request object. Request message for + VideoStitcherService.getVodAdTagDetail + name (str): + Required. The name of the ad tag detail for the + specified VOD session, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{vod_ad_tag_detail}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for VOD sessions that do not + implement Google Ad Manager ad + insertion. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodAdTagDetailRequest): + request = video_stitcher_service.GetVodAdTagDetailRequest(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_vod_ad_tag_detail] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_live_ad_tag_details(self, + request: Optional[Union[video_stitcher_service.ListLiveAdTagDetailsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListLiveAdTagDetailsPager: + r"""Return the list of ad tag details for the specified + live 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.video import stitcher_v1 + + def sample_list_live_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_ad_tag_details(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest, dict]): + The request object. Request message for + VideoStitcherService.listLiveAdTagDetails. + parent (str): + Required. The resource parent in the form of + ``projects/{project}/locations/{location}/liveSessions/{live_session}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager: + Response message for + VideoStitcherService.listLiveAdTagDetails. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListLiveAdTagDetailsRequest): + request = video_stitcher_service.ListLiveAdTagDetailsRequest(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_live_ad_tag_details] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListLiveAdTagDetailsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_live_ad_tag_detail(self, + request: Optional[Union[video_stitcher_service.GetLiveAdTagDetailRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> ad_tag_details.LiveAdTagDetail: + r"""Returns the specified ad tag detail for the specified + live 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.video import stitcher_v1 + + def sample_get_live_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = client.get_live_ad_tag_detail(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest, dict]): + The request object. Request message for + VideoStitcherService.getLiveAdTagDetail + name (str): + Required. The resource name in the form of + ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for live sessions that do not + implement Google Ad Manager ad + insertion. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetLiveAdTagDetailRequest): + request = video_stitcher_service.GetLiveAdTagDetailRequest(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_live_ad_tag_detail] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_slate(self, + request: Optional[Union[video_stitcher_service.CreateSlateRequest, dict]] = None, + *, + parent: Optional[str] = None, + slate: Optional[slates.Slate] = None, + slate_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Creates a slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_create_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateSlateRequest( + parent="parent_value", + slate_id="slate_id_value", + ) + + # Make the request + operation = client.create_slate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.CreateSlateRequest, dict]): + The request object. Request message for + VideoStitcherService.createSlate. + parent (str): + Required. The project in which the slate should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + slate (google.cloud.video.stitcher_v1.types.Slate): + Required. The slate to create. + This corresponds to the ``slate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + slate_id (str): + Required. The unique identifier for + the slate. This value should conform to + RFC-1034, which restricts to lower-case + letters, numbers, and hyphen, with the + first character a letter, the last a + letter or a number, and a 63 character + maximum. + + This corresponds to the ``slate_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.video.stitcher_v1.types.Slate` + Slate object + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, slate, slate_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateSlateRequest): + request = video_stitcher_service.CreateSlateRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if slate is not None: + request.slate = slate + if slate_id is not None: + request.slate_id = slate_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_slate] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + slates.Slate, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_slates(self, + request: Optional[Union[video_stitcher_service.ListSlatesRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListSlatesPager: + r"""Lists all slates in the specified project and + 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.video import stitcher_v1 + + def sample_list_slates(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListSlatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_slates(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.ListSlatesRequest, dict]): + The request object. Request message for + VideoStitcherService.listSlates. + parent (str): + Required. The project to list slates, in the form of + ``projects/{project_number}/locations/{location}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager: + Response message for + VideoStitcherService.listSlates. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListSlatesRequest): + request = video_stitcher_service.ListSlatesRequest(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_slates] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListSlatesPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_slate(self, + request: Optional[Union[video_stitcher_service.GetSlateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> slates.Slate: + r"""Returns the specified slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_get_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetSlateRequest( + name="name_value", + ) + + # Make the request + response = client.get_slate(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetSlateRequest, dict]): + The request object. Request message for + VideoStitcherService.getSlate. + name (str): + Required. The name of the slate to be retrieved, of the + slate, in the form of + ``projects/{project_number}/locations/{location}/slates/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.Slate: + Slate object + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetSlateRequest): + request = video_stitcher_service.GetSlateRequest(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_slate] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_slate(self, + request: Optional[Union[video_stitcher_service.UpdateSlateRequest, dict]] = None, + *, + slate: Optional[slates.Slate] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the specified slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_update_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateSlateRequest( + ) + + # Make the request + operation = client.update_slate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.UpdateSlateRequest, dict]): + The request object. Request message for + VideoStitcherService.updateSlate. + slate (google.cloud.video.stitcher_v1.types.Slate): + Required. The resource with updated + fields. + + This corresponds to the ``slate`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask which + specifies fields which should 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.video.stitcher_v1.types.Slate` + Slate object + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [slate, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateSlateRequest): + request = video_stitcher_service.UpdateSlateRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if slate is not None: + request.slate = slate + 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_slate] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("slate.name", request.slate.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + slates.Slate, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def delete_slate(self, + request: Optional[Union[video_stitcher_service.DeleteSlateRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes the specified slate. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_delete_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteSlateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_slate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.DeleteSlateRequest, dict]): + The request object. Request message for + VideoStitcherService.deleteSlate. + name (str): + Required. The name of the slate to be deleted, in the + form of + ``projects/{project_number}/locations/{location}/slates/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteSlateRequest): + request = video_stitcher_service.DeleteSlateRequest(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_slate] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_live_session(self, + request: Optional[Union[video_stitcher_service.CreateLiveSessionRequest, dict]] = None, + *, + parent: Optional[str] = None, + live_session: Optional[sessions.LiveSession] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.LiveSession: + r"""Creates a new live 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.video import stitcher_v1 + + def sample_create_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + live_session = stitcher_v1.LiveSession() + live_session.live_config = "live_config_value" + + request = stitcher_v1.CreateLiveSessionRequest( + parent="parent_value", + live_session=live_session, + ) + + # Make the request + response = client.create_live_session(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest, dict]): + The request object. Request message for + VideoStitcherService.createLiveSession. + parent (str): + Required. The project and location in which the live + session should be created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + live_session (google.cloud.video.stitcher_v1.types.LiveSession): + Required. Parameters for creating a + live session. + + This corresponds to the ``live_session`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, live_session] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateLiveSessionRequest): + request = video_stitcher_service.CreateLiveSessionRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if live_session is not None: + request.live_session = live_session + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_live_session] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_live_session(self, + request: Optional[Union[video_stitcher_service.GetLiveSessionRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.LiveSession: + r"""Returns the details for the specified live 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.video import stitcher_v1 + + def sample_get_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveSessionRequest( + name="name_value", + ) + + # Make the request + response = client.get_live_session(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetLiveSessionRequest, dict]): + The request object. Request message for + VideoStitcherService.getSession. + name (str): + Required. The name of the live session, in the form of + ``projects/{project_number}/locations/{location}/liveSessions/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetLiveSessionRequest): + request = video_stitcher_service.GetLiveSessionRequest(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_live_session] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def create_live_config(self, + request: Optional[Union[video_stitcher_service.CreateLiveConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + live_config: Optional[live_configs.LiveConfig] = None, + live_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Registers the live config with the provided unique ID + in the specified region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_create_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.CreateLiveConfigRequest( + parent="parent_value", + live_config_id="live_config_id_value", + live_config=live_config, + ) + + # Make the request + operation = client.create_live_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.createLiveConfig + parent (str): + Required. The project in which the live config should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + live_config (google.cloud.video.stitcher_v1.types.LiveConfig): + Required. The live config resource to + create. + + This corresponds to the ``live_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + live_config_id (str): + Required. The unique identifier ID to + use for the live config. + + This corresponds to the ``live_config_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.video.stitcher_v1.types.LiveConfig` + Metadata for used to register live configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, live_config, live_config_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateLiveConfigRequest): + request = video_stitcher_service.CreateLiveConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if live_config is not None: + request.live_config = live_config + if live_config_id is not None: + request.live_config_id = live_config_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_live_config] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + live_configs.LiveConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_live_configs(self, + request: Optional[Union[video_stitcher_service.ListLiveConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListLiveConfigsPager: + r"""Lists all live configs managed by the Video Stitcher + that belong to the specified project and region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_list_live_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest, dict]): + The request object. Request message for + VideoStitcherService.listLiveConfig. + parent (str): + Required. The project that contains the list of live + configs, in the form of + ``projects/{project_number}/locations/{location}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager: + Response message for + VideoStitcher.ListLiveConfig. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListLiveConfigsRequest): + request = video_stitcher_service.ListLiveConfigsRequest(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_live_configs] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListLiveConfigsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_live_config(self, + request: Optional[Union[video_stitcher_service.GetLiveConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> live_configs.LiveConfig: + r"""Returns the specified live config managed by the + Video Stitcher service. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_get_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_live_config(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetLiveConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.getLiveConfig. + name (str): + Required. The name of the live config to be retrieved, + in the form of + ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.LiveConfig: + Metadata for used to register live + configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetLiveConfigRequest): + request = video_stitcher_service.GetLiveConfigRequest(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_live_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_live_config(self, + request: Optional[Union[video_stitcher_service.DeleteLiveConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes the specified live config. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_delete_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteLiveConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_live_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.deleteLiveConfig. + name (str): + Required. The name of the live config to be deleted, in + the form of + ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteLiveConfigRequest): + request = video_stitcher_service.DeleteLiveConfigRequest(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_live_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_live_config(self, + request: Optional[Union[video_stitcher_service.UpdateLiveConfigRequest, dict]] = None, + *, + live_config: Optional[live_configs.LiveConfig] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the specified LiveConfig. Only update fields + specified in the call method body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_update_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.UpdateLiveConfigRequest( + live_config=live_config, + ) + + # Make the request + operation = client.update_live_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.updateLiveConfig. + live_config (google.cloud.video.stitcher_v1.types.LiveConfig): + Required. The LiveConfig resource + which replaces the resource on the + server. + + This corresponds to the ``live_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.video.stitcher_v1.types.LiveConfig` + Metadata for used to register live configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [live_config, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateLiveConfigRequest): + request = video_stitcher_service.UpdateLiveConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if live_config is not None: + request.live_config = live_config + 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_live_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("live_config.name", request.live_config.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + live_configs.LiveConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def create_vod_config(self, + request: Optional[Union[video_stitcher_service.CreateVodConfigRequest, dict]] = None, + *, + parent: Optional[str] = None, + vod_config: Optional[vod_configs.VodConfig] = None, + vod_config_id: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Registers the VOD config with the provided unique ID + in the specified region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_create_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.CreateVodConfigRequest( + parent="parent_value", + vod_config_id="vod_config_id_value", + vod_config=vod_config, + ) + + # Make the request + operation = client.create_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.CreateVodConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.createVodConfig + parent (str): + Required. The project in which the VOD config should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vod_config (google.cloud.video.stitcher_v1.types.VodConfig): + Required. The VOD config resource to + create. + + This corresponds to the ``vod_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + vod_config_id (str): + Required. The unique identifier ID to + use for the VOD config. + + This corresponds to the ``vod_config_id`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.video.stitcher_v1.types.VodConfig` + Metadata used to register VOD configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [parent, vod_config, vod_config_id] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.CreateVodConfigRequest): + request = video_stitcher_service.CreateVodConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if vod_config is not None: + request.vod_config = vod_config + if vod_config_id is not None: + request.vod_config_id = vod_config_id + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_vod_config] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + vod_configs.VodConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def list_vod_configs(self, + request: Optional[Union[video_stitcher_service.ListVodConfigsRequest, dict]] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> pagers.ListVodConfigsPager: + r"""Lists all VOD configs managed by the Video Stitcher + API that belong to the specified project and region. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_list_vod_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.ListVodConfigsRequest, dict]): + The request object. Request message for + VideoStitcherService.listVodConfig. + parent (str): + Required. The project that contains the list of VOD + configs, in the form of + ``projects/{project_number}/locations/{location}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager: + Response message for + VideoStitcher.ListVodConfig. + 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. + flattened_params = [parent] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.ListVodConfigsRequest): + request = video_stitcher_service.ListVodConfigsRequest(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_vod_configs] + + # 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), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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.ListVodConfigsPager( + method=rpc, + request=request, + response=response, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_vod_config(self, + request: Optional[Union[video_stitcher_service.GetVodConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> vod_configs.VodConfig: + r"""Returns the specified VOD config managed by the Video + Stitcher API service. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_get_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_config(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.GetVodConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.getVodConfig. + name (str): + Required. The name of the VOD config to be retrieved, in + the form of + ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.cloud.video.stitcher_v1.types.VodConfig: + Metadata used to register VOD + configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.GetVodConfigRequest): + request = video_stitcher_service.GetVodConfigRequest(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_vod_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_vod_config(self, + request: Optional[Union[video_stitcher_service.DeleteVodConfigRequest, dict]] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Deletes the specified VOD config. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_delete_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteVodConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.deleteVodConfig. + name (str): + Required. The name of the VOD config to be deleted, in + the form of + ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + 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. + flattened_params = [name] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.DeleteVodConfigRequest): + request = video_stitcher_service.DeleteVodConfigRequest(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_vod_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("name", request.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def update_vod_config(self, + request: Optional[Union[video_stitcher_service.UpdateVodConfigRequest, dict]] = None, + *, + vod_config: Optional[vod_configs.VodConfig] = 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, Union[str, bytes]]] = (), + ) -> operation.Operation: + r"""Updates the specified VOD config. Only update fields + specified in the call method body. + + .. code-block:: python + + # This snippet has been automatically generated and should be regarded as a + # code template only. + # It will require modifications to work: + # - It may require correct/in-range values for request initialization. + # - It may require specifying regional endpoints when creating the service + # client as shown in: + # https://googleapis.dev/python/google-api-core/latest/client_options.html + from google.cloud.video import stitcher_v1 + + def sample_update_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.UpdateVodConfigRequest( + vod_config=vod_config, + ) + + # Make the request + operation = client.update_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest, dict]): + The request object. Request message for + VideoStitcherService.updateVodConfig. + vod_config (google.cloud.video.stitcher_v1.types.VodConfig): + Required. The VOD config resource + which replaces the resource on the + server. + + This corresponds to the ``vod_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For + the ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + + 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + google.api_core.operation.Operation: + An object representing a long-running operation. + + The result type for the operation will be + :class:`google.cloud.video.stitcher_v1.types.VodConfig` + Metadata used to register VOD configs. + + """ + # Create or coerce a protobuf request object. + # - Quick check: If we got a request object, we should *not* have + # gotten any keyword arguments that map to the request. + flattened_params = [vod_config, update_mask] + has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 + if request is not None and has_flattened_params: + raise ValueError('If the `request` argument is set, then none of ' + 'the individual field arguments should be set.') + + # - Use the request object if provided (there's no risk of modifying the input as + # there are no flattened fields), or create one. + if not isinstance(request, video_stitcher_service.UpdateVodConfigRequest): + request = video_stitcher_service.UpdateVodConfigRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if vod_config is not None: + request.vod_config = vod_config + 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_vod_config] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("vod_config.name", request.vod_config.name), + )), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # 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, + vod_configs.VodConfig, + metadata_type=video_stitcher_service.OperationMetadata, + ) + + # Done; return the response. + return response + + def __enter__(self) -> "VideoStitcherServiceClient": + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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 = self._transport._wrapped_methods[self._transport.list_operations] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + try: + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + except core_exceptions.GoogleAPICallError as e: + self._add_cred_info_for_auth_errors(e) + raise e + + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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 = self._transport._wrapped_methods[self._transport.get_operation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + try: + # Send the request. + response = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + except core_exceptions.GoogleAPICallError as e: + self._add_cred_info_for_auth_errors(e) + raise e + + def delete_operation( + self, + request: Optional[operations_pb2.DeleteOperationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> None: + r"""Deletes a long-running operation. + + This method indicates that the client is no longer interested + in the operation result. It does not cancel the operation. + If the server doesn't support this method, it returns + `google.rpc.Code.UNIMPLEMENTED`. + + Args: + request (:class:`~.operations_pb2.DeleteOperationRequest`): + The request object. Request message for + `DeleteOperation` method. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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.DeleteOperationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_operation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + 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, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + 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 = self._transport._wrapped_methods[self._transport.cancel_operation] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("name", request.name),)), + ) + + # Validate the universe domain. + self._validate_universe_domain() + + # Send the request. + rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + + + + + + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + +if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER + DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ + +__all__ = ( + "VideoStitcherServiceClient", +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py new file mode 100644 index 000000000000..ecdde06e2b11 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py @@ -0,0 +1,1006 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import retry_async as retries_async +from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator, Union +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] + OptionalAsyncRetry = Union[retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object, None] # type: ignore + OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore + +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs + + +class ListCdnKeysPager: + """A pager for iterating through ``list_cdn_keys`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` object, and + provides an ``__iter__`` method to iterate through its + ``cdn_keys`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListCdnKeys`` requests and continue to iterate + through the ``cdn_keys`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` + 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[..., video_stitcher_service.ListCdnKeysResponse], + request: video_stitcher_service.ListCdnKeysRequest, + response: video_stitcher_service.ListCdnKeysResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListCdnKeysRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListCdnKeysResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListCdnKeysRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[video_stitcher_service.ListCdnKeysResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[cdn_keys.CdnKey]: + for page in self.pages: + yield from page.cdn_keys + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListCdnKeysAsyncPager: + """A pager for iterating through ``list_cdn_keys`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``cdn_keys`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListCdnKeys`` requests and continue to iterate + through the ``cdn_keys`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` + 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[video_stitcher_service.ListCdnKeysResponse]], + request: video_stitcher_service.ListCdnKeysRequest, + response: video_stitcher_service.ListCdnKeysResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListCdnKeysRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListCdnKeysResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListCdnKeysRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[video_stitcher_service.ListCdnKeysResponse]: + 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[cdn_keys.CdnKey]: + async def async_generator(): + async for page in self.pages: + for response in page.cdn_keys: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVodStitchDetailsPager: + """A pager for iterating through ``list_vod_stitch_details`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``vod_stitch_details`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListVodStitchDetails`` requests and continue to iterate + through the ``vod_stitch_details`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` + 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[..., video_stitcher_service.ListVodStitchDetailsResponse], + request: video_stitcher_service.ListVodStitchDetailsRequest, + response: video_stitcher_service.ListVodStitchDetailsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListVodStitchDetailsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[video_stitcher_service.ListVodStitchDetailsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[stitch_details.VodStitchDetail]: + for page in self.pages: + yield from page.vod_stitch_details + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVodStitchDetailsAsyncPager: + """A pager for iterating through ``list_vod_stitch_details`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``vod_stitch_details`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListVodStitchDetails`` requests and continue to iterate + through the ``vod_stitch_details`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` + 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[video_stitcher_service.ListVodStitchDetailsResponse]], + request: video_stitcher_service.ListVodStitchDetailsRequest, + response: video_stitcher_service.ListVodStitchDetailsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListVodStitchDetailsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[video_stitcher_service.ListVodStitchDetailsResponse]: + 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[stitch_details.VodStitchDetail]: + async def async_generator(): + async for page in self.pages: + for response in page.vod_stitch_details: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVodAdTagDetailsPager: + """A pager for iterating through ``list_vod_ad_tag_details`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``vod_ad_tag_details`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListVodAdTagDetails`` requests and continue to iterate + through the ``vod_ad_tag_details`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` + 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[..., video_stitcher_service.ListVodAdTagDetailsResponse], + request: video_stitcher_service.ListVodAdTagDetailsRequest, + response: video_stitcher_service.ListVodAdTagDetailsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListVodAdTagDetailsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[video_stitcher_service.ListVodAdTagDetailsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[ad_tag_details.VodAdTagDetail]: + for page in self.pages: + yield from page.vod_ad_tag_details + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVodAdTagDetailsAsyncPager: + """A pager for iterating through ``list_vod_ad_tag_details`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``vod_ad_tag_details`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListVodAdTagDetails`` requests and continue to iterate + through the ``vod_ad_tag_details`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` + 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[video_stitcher_service.ListVodAdTagDetailsResponse]], + request: video_stitcher_service.ListVodAdTagDetailsRequest, + response: video_stitcher_service.ListVodAdTagDetailsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListVodAdTagDetailsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[video_stitcher_service.ListVodAdTagDetailsResponse]: + 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[ad_tag_details.VodAdTagDetail]: + async def async_generator(): + async for page in self.pages: + for response in page.vod_ad_tag_details: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListLiveAdTagDetailsPager: + """A pager for iterating through ``list_live_ad_tag_details`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``live_ad_tag_details`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListLiveAdTagDetails`` requests and continue to iterate + through the ``live_ad_tag_details`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` + 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[..., video_stitcher_service.ListLiveAdTagDetailsResponse], + request: video_stitcher_service.ListLiveAdTagDetailsRequest, + response: video_stitcher_service.ListLiveAdTagDetailsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListLiveAdTagDetailsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[video_stitcher_service.ListLiveAdTagDetailsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[ad_tag_details.LiveAdTagDetail]: + for page in self.pages: + yield from page.live_ad_tag_details + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListLiveAdTagDetailsAsyncPager: + """A pager for iterating through ``list_live_ad_tag_details`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``live_ad_tag_details`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListLiveAdTagDetails`` requests and continue to iterate + through the ``live_ad_tag_details`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` + 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[video_stitcher_service.ListLiveAdTagDetailsResponse]], + request: video_stitcher_service.ListLiveAdTagDetailsRequest, + response: video_stitcher_service.ListLiveAdTagDetailsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListLiveAdTagDetailsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[video_stitcher_service.ListLiveAdTagDetailsResponse]: + 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[ad_tag_details.LiveAdTagDetail]: + async def async_generator(): + async for page in self.pages: + for response in page.live_ad_tag_details: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSlatesPager: + """A pager for iterating through ``list_slates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``slates`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListSlates`` requests and continue to iterate + through the ``slates`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` + 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[..., video_stitcher_service.ListSlatesResponse], + request: video_stitcher_service.ListSlatesRequest, + response: video_stitcher_service.ListSlatesResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListSlatesRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListSlatesResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListSlatesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[video_stitcher_service.ListSlatesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[slates.Slate]: + for page in self.pages: + yield from page.slates + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSlatesAsyncPager: + """A pager for iterating through ``list_slates`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``slates`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListSlates`` requests and continue to iterate + through the ``slates`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` + 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[video_stitcher_service.ListSlatesResponse]], + request: video_stitcher_service.ListSlatesRequest, + response: video_stitcher_service.ListSlatesResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListSlatesRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListSlatesResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListSlatesRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[video_stitcher_service.ListSlatesResponse]: + 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[slates.Slate]: + async def async_generator(): + async for page in self.pages: + for response in page.slates: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListLiveConfigsPager: + """A pager for iterating through ``list_live_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``live_configs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListLiveConfigs`` requests and continue to iterate + through the ``live_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` + 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[..., video_stitcher_service.ListLiveConfigsResponse], + request: video_stitcher_service.ListLiveConfigsRequest, + response: video_stitcher_service.ListLiveConfigsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListLiveConfigsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[video_stitcher_service.ListLiveConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[live_configs.LiveConfig]: + for page in self.pages: + yield from page.live_configs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListLiveConfigsAsyncPager: + """A pager for iterating through ``list_live_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``live_configs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListLiveConfigs`` requests and continue to iterate + through the ``live_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` + 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[video_stitcher_service.ListLiveConfigsResponse]], + request: video_stitcher_service.ListLiveConfigsRequest, + response: video_stitcher_service.ListLiveConfigsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListLiveConfigsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[video_stitcher_service.ListLiveConfigsResponse]: + 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[live_configs.LiveConfig]: + async def async_generator(): + async for page in self.pages: + for response in page.live_configs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVodConfigsPager: + """A pager for iterating through ``list_vod_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` object, and + provides an ``__iter__`` method to iterate through its + ``vod_configs`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListVodConfigs`` requests and continue to iterate + through the ``vod_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` + 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[..., video_stitcher_service.ListVodConfigsResponse], + request: video_stitcher_service.ListVodConfigsRequest, + response: video_stitcher_service.ListVodConfigsResponse, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListVodConfigsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListVodConfigsResponse): + The initial response object. + retry (google.api_core.retry.Retry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListVodConfigsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[video_stitcher_service.ListVodConfigsResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[vod_configs.VodConfig]: + for page in self.pages: + yield from page.vod_configs + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListVodConfigsAsyncPager: + """A pager for iterating through ``list_vod_configs`` requests. + + This class thinly wraps an initial + :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``vod_configs`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListVodConfigs`` requests and continue to iterate + through the ``vod_configs`` field on the + corresponding responses. + + All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` + 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[video_stitcher_service.ListVodConfigsResponse]], + request: video_stitcher_service.ListVodConfigsRequest, + response: video_stitcher_service.ListVodConfigsResponse, + *, + retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.video.stitcher_v1.types.ListVodConfigsRequest): + The initial request object. + response (google.cloud.video.stitcher_v1.types.ListVodConfigsResponse): + The initial response object. + retry (google.api_core.retry.AsyncRetry): Designation of what errors, + if any, should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + self._method = method + self._request = video_stitcher_service.ListVodConfigsRequest(request) + self._response = response + self._retry = retry + self._timeout = timeout + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[video_stitcher_service.ListVodConfigsResponse]: + 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) + yield self._response + def __aiter__(self) -> AsyncIterator[vod_configs.VodConfig]: + async def async_generator(): + async for page in self.pages: + for response in page.vod_configs: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst new file mode 100644 index 000000000000..b28f3c61e27f --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst @@ -0,0 +1,9 @@ + +transport inheritance structure +_______________________________ + +`VideoStitcherServiceTransport` is the ABC for all transports. +- public child `VideoStitcherServiceGrpcTransport` for sync gRPC transport (defined in `grpc.py`). +- public child `VideoStitcherServiceGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). +- private child `_BaseVideoStitcherServiceRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). +- public child `VideoStitcherServiceRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`). diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py new file mode 100644 index 000000000000..0498bf5348c2 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 VideoStitcherServiceTransport +from .grpc import VideoStitcherServiceGrpcTransport +from .grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport +from .rest import VideoStitcherServiceRestTransport +from .rest import VideoStitcherServiceRestInterceptor + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[VideoStitcherServiceTransport]] +_transport_registry['grpc'] = VideoStitcherServiceGrpcTransport +_transport_registry['grpc_asyncio'] = VideoStitcherServiceGrpcAsyncIOTransport +_transport_registry['rest'] = VideoStitcherServiceRestTransport + +__all__ = ( + 'VideoStitcherServiceTransport', + 'VideoStitcherServiceGrpcTransport', + 'VideoStitcherServiceGrpcAsyncIOTransport', + 'VideoStitcherServiceRestTransport', + 'VideoStitcherServiceRestInterceptor', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py new file mode 100644 index 000000000000..5d82d004a057 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py @@ -0,0 +1,635 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher_v1 import gapic_version as package_version + +import google.auth # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore +import google.protobuf + +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + +if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER + DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ + + +class VideoStitcherServiceTransport(abc.ABC): + """Abstract transport class for VideoStitcherService.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'videostitcher.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 (default: 'videostitcher.googleapis.com'). + 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 not hasattr(self, "_ignore_credentials"): + self._ignore_credentials: bool = False + + # 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 and not self._ignore_credentials: + 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 + + @property + def host(self): + return self._host + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.create_cdn_key: gapic_v1.method.wrap_method( + self.create_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.list_cdn_keys: gapic_v1.method.wrap_method( + self.list_cdn_keys, + default_timeout=60.0, + client_info=client_info, + ), + self.get_cdn_key: gapic_v1.method.wrap_method( + self.get_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_cdn_key: gapic_v1.method.wrap_method( + self.delete_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.update_cdn_key: gapic_v1.method.wrap_method( + self.update_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.create_vod_session: gapic_v1.method.wrap_method( + self.create_vod_session, + default_timeout=60.0, + client_info=client_info, + ), + self.get_vod_session: gapic_v1.method.wrap_method( + self.get_vod_session, + default_timeout=60.0, + client_info=client_info, + ), + self.list_vod_stitch_details: gapic_v1.method.wrap_method( + self.list_vod_stitch_details, + default_timeout=60.0, + client_info=client_info, + ), + self.get_vod_stitch_detail: gapic_v1.method.wrap_method( + self.get_vod_stitch_detail, + default_timeout=60.0, + client_info=client_info, + ), + self.list_vod_ad_tag_details: gapic_v1.method.wrap_method( + self.list_vod_ad_tag_details, + default_timeout=60.0, + client_info=client_info, + ), + self.get_vod_ad_tag_detail: gapic_v1.method.wrap_method( + self.get_vod_ad_tag_detail, + default_timeout=60.0, + client_info=client_info, + ), + self.list_live_ad_tag_details: gapic_v1.method.wrap_method( + self.list_live_ad_tag_details, + default_timeout=60.0, + client_info=client_info, + ), + self.get_live_ad_tag_detail: gapic_v1.method.wrap_method( + self.get_live_ad_tag_detail, + default_timeout=60.0, + client_info=client_info, + ), + self.create_slate: gapic_v1.method.wrap_method( + self.create_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.list_slates: gapic_v1.method.wrap_method( + self.list_slates, + default_timeout=60.0, + client_info=client_info, + ), + self.get_slate: gapic_v1.method.wrap_method( + self.get_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.update_slate: gapic_v1.method.wrap_method( + self.update_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_slate: gapic_v1.method.wrap_method( + self.delete_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.create_live_session: gapic_v1.method.wrap_method( + self.create_live_session, + default_timeout=60.0, + client_info=client_info, + ), + self.get_live_session: gapic_v1.method.wrap_method( + self.get_live_session, + default_timeout=60.0, + client_info=client_info, + ), + self.create_live_config: gapic_v1.method.wrap_method( + self.create_live_config, + default_timeout=60.0, + client_info=client_info, + ), + self.list_live_configs: gapic_v1.method.wrap_method( + self.list_live_configs, + default_timeout=60.0, + client_info=client_info, + ), + self.get_live_config: gapic_v1.method.wrap_method( + self.get_live_config, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_live_config: gapic_v1.method.wrap_method( + self.delete_live_config, + default_timeout=60.0, + client_info=client_info, + ), + self.update_live_config: gapic_v1.method.wrap_method( + self.update_live_config, + default_timeout=None, + client_info=client_info, + ), + self.create_vod_config: gapic_v1.method.wrap_method( + self.create_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.list_vod_configs: gapic_v1.method.wrap_method( + self.list_vod_configs, + default_timeout=None, + client_info=client_info, + ), + self.get_vod_config: gapic_v1.method.wrap_method( + self.get_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.delete_vod_config: gapic_v1.method.wrap_method( + self.delete_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.update_vod_config: gapic_v1.method.wrap_method( + self.update_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.cancel_operation: gapic_v1.method.wrap_method( + self.cancel_operation, + default_timeout=None, + client_info=client_info, + ), + self.delete_operation: gapic_v1.method.wrap_method( + self.delete_operation, + default_timeout=None, + client_info=client_info, + ), + self.get_operation: gapic_v1.method.wrap_method( + self.get_operation, + default_timeout=None, + client_info=client_info, + ), + self.list_operations: gapic_v1.method.wrap_method( + self.list_operations, + 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_cdn_key(self) -> Callable[ + [video_stitcher_service.CreateCdnKeyRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_cdn_keys(self) -> Callable[ + [video_stitcher_service.ListCdnKeysRequest], + Union[ + video_stitcher_service.ListCdnKeysResponse, + Awaitable[video_stitcher_service.ListCdnKeysResponse] + ]]: + raise NotImplementedError() + + @property + def get_cdn_key(self) -> Callable[ + [video_stitcher_service.GetCdnKeyRequest], + Union[ + cdn_keys.CdnKey, + Awaitable[cdn_keys.CdnKey] + ]]: + raise NotImplementedError() + + @property + def delete_cdn_key(self) -> Callable[ + [video_stitcher_service.DeleteCdnKeyRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_cdn_key(self) -> Callable[ + [video_stitcher_service.UpdateCdnKeyRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_vod_session(self) -> Callable[ + [video_stitcher_service.CreateVodSessionRequest], + Union[ + sessions.VodSession, + Awaitable[sessions.VodSession] + ]]: + raise NotImplementedError() + + @property + def get_vod_session(self) -> Callable[ + [video_stitcher_service.GetVodSessionRequest], + Union[ + sessions.VodSession, + Awaitable[sessions.VodSession] + ]]: + raise NotImplementedError() + + @property + def list_vod_stitch_details(self) -> Callable[ + [video_stitcher_service.ListVodStitchDetailsRequest], + Union[ + video_stitcher_service.ListVodStitchDetailsResponse, + Awaitable[video_stitcher_service.ListVodStitchDetailsResponse] + ]]: + raise NotImplementedError() + + @property + def get_vod_stitch_detail(self) -> Callable[ + [video_stitcher_service.GetVodStitchDetailRequest], + Union[ + stitch_details.VodStitchDetail, + Awaitable[stitch_details.VodStitchDetail] + ]]: + raise NotImplementedError() + + @property + def list_vod_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListVodAdTagDetailsRequest], + Union[ + video_stitcher_service.ListVodAdTagDetailsResponse, + Awaitable[video_stitcher_service.ListVodAdTagDetailsResponse] + ]]: + raise NotImplementedError() + + @property + def get_vod_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetVodAdTagDetailRequest], + Union[ + ad_tag_details.VodAdTagDetail, + Awaitable[ad_tag_details.VodAdTagDetail] + ]]: + raise NotImplementedError() + + @property + def list_live_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListLiveAdTagDetailsRequest], + Union[ + video_stitcher_service.ListLiveAdTagDetailsResponse, + Awaitable[video_stitcher_service.ListLiveAdTagDetailsResponse] + ]]: + raise NotImplementedError() + + @property + def get_live_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetLiveAdTagDetailRequest], + Union[ + ad_tag_details.LiveAdTagDetail, + Awaitable[ad_tag_details.LiveAdTagDetail] + ]]: + raise NotImplementedError() + + @property + def create_slate(self) -> Callable[ + [video_stitcher_service.CreateSlateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_slates(self) -> Callable[ + [video_stitcher_service.ListSlatesRequest], + Union[ + video_stitcher_service.ListSlatesResponse, + Awaitable[video_stitcher_service.ListSlatesResponse] + ]]: + raise NotImplementedError() + + @property + def get_slate(self) -> Callable[ + [video_stitcher_service.GetSlateRequest], + Union[ + slates.Slate, + Awaitable[slates.Slate] + ]]: + raise NotImplementedError() + + @property + def update_slate(self) -> Callable[ + [video_stitcher_service.UpdateSlateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def delete_slate(self) -> Callable[ + [video_stitcher_service.DeleteSlateRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_live_session(self) -> Callable[ + [video_stitcher_service.CreateLiveSessionRequest], + Union[ + sessions.LiveSession, + Awaitable[sessions.LiveSession] + ]]: + raise NotImplementedError() + + @property + def get_live_session(self) -> Callable[ + [video_stitcher_service.GetLiveSessionRequest], + Union[ + sessions.LiveSession, + Awaitable[sessions.LiveSession] + ]]: + raise NotImplementedError() + + @property + def create_live_config(self) -> Callable[ + [video_stitcher_service.CreateLiveConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_live_configs(self) -> Callable[ + [video_stitcher_service.ListLiveConfigsRequest], + Union[ + video_stitcher_service.ListLiveConfigsResponse, + Awaitable[video_stitcher_service.ListLiveConfigsResponse] + ]]: + raise NotImplementedError() + + @property + def get_live_config(self) -> Callable[ + [video_stitcher_service.GetLiveConfigRequest], + Union[ + live_configs.LiveConfig, + Awaitable[live_configs.LiveConfig] + ]]: + raise NotImplementedError() + + @property + def delete_live_config(self) -> Callable[ + [video_stitcher_service.DeleteLiveConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_live_config(self) -> Callable[ + [video_stitcher_service.UpdateLiveConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def create_vod_config(self) -> Callable[ + [video_stitcher_service.CreateVodConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def list_vod_configs(self) -> Callable[ + [video_stitcher_service.ListVodConfigsRequest], + Union[ + video_stitcher_service.ListVodConfigsResponse, + Awaitable[video_stitcher_service.ListVodConfigsResponse] + ]]: + raise NotImplementedError() + + @property + def get_vod_config(self) -> Callable[ + [video_stitcher_service.GetVodConfigRequest], + Union[ + vod_configs.VodConfig, + Awaitable[vod_configs.VodConfig] + ]]: + raise NotImplementedError() + + @property + def delete_vod_config(self) -> Callable[ + [video_stitcher_service.DeleteVodConfigRequest], + Union[ + operations_pb2.Operation, + Awaitable[operations_pb2.Operation] + ]]: + raise NotImplementedError() + + @property + def update_vod_config(self) -> Callable[ + [video_stitcher_service.UpdateVodConfigRequest], + 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 delete_operation( + self, + ) -> Callable[ + [operations_pb2.DeleteOperationRequest], + None, + ]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'VideoStitcherServiceTransport', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py new file mode 100644 index 000000000000..44e6aa81768a --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py @@ -0,0 +1,1222 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 json +import logging as std_logging +import pickle +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 +from google.protobuf.json_format import MessageToJson +import google.protobuf.message + +import grpc # type: ignore +import proto # type: ignore + +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore +from .base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + + +class VideoStitcherServiceGrpcTransport(VideoStitcherServiceTransport): + """gRPC backend transport for VideoStitcherService. + + Video-On-Demand content stitching API allows you to insert + ads into (VoD) video on demand files. You will be able to render + custom scrubber bars with highlighted ads, enforce ad policies, + allow seamless playback and tracking on native players and + monetize content with any standard VMAP compliant ad server. + + 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 = 'videostitcher.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[Union[grpc.Channel, Callable[..., 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 (default: 'videostitcher.googleapis.com'). + 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 a ``channel`` instance 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 a ``channel`` instance is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if a ``channel`` instance is provided. + channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): + A ``Channel`` instance through which to make calls, or a Callable + that constructs and returns one. If set to None, ``self.create_channel`` + is used to create the channel. If a Callable is given, it will be called + with the same arguments as used in ``self.create_channel``. + 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 a ``channel`` instance 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 a ``channel`` instance 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 isinstance(channel, grpc.Channel): + # Ignore credentials if a channel was passed. + credentials = None + self._ignore_credentials = True + # 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: + # initialize with the provided callable or the default channel + channel_init = channel or type(self).create_channel + self._grpc_channel = channel_init( + 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), + ], + ) + + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel(self._grpc_channel, self._interceptor) + + # Wrap messages. This must be done after self._logged_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'videostitcher.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._logged_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_cdn_key(self) -> Callable[ + [video_stitcher_service.CreateCdnKeyRequest], + operations_pb2.Operation]: + r"""Return a callable for the create cdn key method over gRPC. + + Creates a new CDN key. + + Returns: + Callable[[~.CreateCdnKeyRequest], + ~.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_cdn_key' not in self._stubs: + self._stubs['create_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateCdnKey', + request_serializer=video_stitcher_service.CreateCdnKeyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_cdn_key'] + + @property + def list_cdn_keys(self) -> Callable[ + [video_stitcher_service.ListCdnKeysRequest], + video_stitcher_service.ListCdnKeysResponse]: + r"""Return a callable for the list cdn keys method over gRPC. + + Lists all CDN keys in the specified project and + location. + + Returns: + Callable[[~.ListCdnKeysRequest], + ~.ListCdnKeysResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_cdn_keys' not in self._stubs: + self._stubs['list_cdn_keys'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListCdnKeys', + request_serializer=video_stitcher_service.ListCdnKeysRequest.serialize, + response_deserializer=video_stitcher_service.ListCdnKeysResponse.deserialize, + ) + return self._stubs['list_cdn_keys'] + + @property + def get_cdn_key(self) -> Callable[ + [video_stitcher_service.GetCdnKeyRequest], + cdn_keys.CdnKey]: + r"""Return a callable for the get cdn key method over gRPC. + + Returns the specified CDN key. + + Returns: + Callable[[~.GetCdnKeyRequest], + ~.CdnKey]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_cdn_key' not in self._stubs: + self._stubs['get_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetCdnKey', + request_serializer=video_stitcher_service.GetCdnKeyRequest.serialize, + response_deserializer=cdn_keys.CdnKey.deserialize, + ) + return self._stubs['get_cdn_key'] + + @property + def delete_cdn_key(self) -> Callable[ + [video_stitcher_service.DeleteCdnKeyRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete cdn key method over gRPC. + + Deletes the specified CDN key. + + Returns: + Callable[[~.DeleteCdnKeyRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_cdn_key' not in self._stubs: + self._stubs['delete_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteCdnKey', + request_serializer=video_stitcher_service.DeleteCdnKeyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_cdn_key'] + + @property + def update_cdn_key(self) -> Callable[ + [video_stitcher_service.UpdateCdnKeyRequest], + operations_pb2.Operation]: + r"""Return a callable for the update cdn key method over gRPC. + + Updates the specified CDN key. Only update fields + specified in the call method body. + + Returns: + Callable[[~.UpdateCdnKeyRequest], + ~.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_cdn_key' not in self._stubs: + self._stubs['update_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateCdnKey', + request_serializer=video_stitcher_service.UpdateCdnKeyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_cdn_key'] + + @property + def create_vod_session(self) -> Callable[ + [video_stitcher_service.CreateVodSessionRequest], + sessions.VodSession]: + r"""Return a callable for the create vod session method over gRPC. + + Creates a client side playback VOD session and + returns the full tracking and playback metadata of the + session. + + Returns: + Callable[[~.CreateVodSessionRequest], + ~.VodSession]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_session' not in self._stubs: + self._stubs['create_vod_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodSession', + request_serializer=video_stitcher_service.CreateVodSessionRequest.serialize, + response_deserializer=sessions.VodSession.deserialize, + ) + return self._stubs['create_vod_session'] + + @property + def get_vod_session(self) -> Callable[ + [video_stitcher_service.GetVodSessionRequest], + sessions.VodSession]: + r"""Return a callable for the get vod session method over gRPC. + + Returns the full tracking, playback metadata, and + relevant ad-ops logs for the specified VOD session. + + Returns: + Callable[[~.GetVodSessionRequest], + ~.VodSession]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_session' not in self._stubs: + self._stubs['get_vod_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodSession', + request_serializer=video_stitcher_service.GetVodSessionRequest.serialize, + response_deserializer=sessions.VodSession.deserialize, + ) + return self._stubs['get_vod_session'] + + @property + def list_vod_stitch_details(self) -> Callable[ + [video_stitcher_service.ListVodStitchDetailsRequest], + video_stitcher_service.ListVodStitchDetailsResponse]: + r"""Return a callable for the list vod stitch details method over gRPC. + + Returns a list of detailed stitching information of + the specified VOD session. + + Returns: + Callable[[~.ListVodStitchDetailsRequest], + ~.ListVodStitchDetailsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_stitch_details' not in self._stubs: + self._stubs['list_vod_stitch_details'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodStitchDetails', + request_serializer=video_stitcher_service.ListVodStitchDetailsRequest.serialize, + response_deserializer=video_stitcher_service.ListVodStitchDetailsResponse.deserialize, + ) + return self._stubs['list_vod_stitch_details'] + + @property + def get_vod_stitch_detail(self) -> Callable[ + [video_stitcher_service.GetVodStitchDetailRequest], + stitch_details.VodStitchDetail]: + r"""Return a callable for the get vod stitch detail method over gRPC. + + Returns the specified stitching information for the + specified VOD session. + + Returns: + Callable[[~.GetVodStitchDetailRequest], + ~.VodStitchDetail]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_stitch_detail' not in self._stubs: + self._stubs['get_vod_stitch_detail'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodStitchDetail', + request_serializer=video_stitcher_service.GetVodStitchDetailRequest.serialize, + response_deserializer=stitch_details.VodStitchDetail.deserialize, + ) + return self._stubs['get_vod_stitch_detail'] + + @property + def list_vod_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListVodAdTagDetailsRequest], + video_stitcher_service.ListVodAdTagDetailsResponse]: + r"""Return a callable for the list vod ad tag details method over gRPC. + + Return the list of ad tag details for the specified + VOD session. + + Returns: + Callable[[~.ListVodAdTagDetailsRequest], + ~.ListVodAdTagDetailsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_ad_tag_details' not in self._stubs: + self._stubs['list_vod_ad_tag_details'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodAdTagDetails', + request_serializer=video_stitcher_service.ListVodAdTagDetailsRequest.serialize, + response_deserializer=video_stitcher_service.ListVodAdTagDetailsResponse.deserialize, + ) + return self._stubs['list_vod_ad_tag_details'] + + @property + def get_vod_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetVodAdTagDetailRequest], + ad_tag_details.VodAdTagDetail]: + r"""Return a callable for the get vod ad tag detail method over gRPC. + + Returns the specified ad tag detail for the specified + VOD session. + + Returns: + Callable[[~.GetVodAdTagDetailRequest], + ~.VodAdTagDetail]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_ad_tag_detail' not in self._stubs: + self._stubs['get_vod_ad_tag_detail'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodAdTagDetail', + request_serializer=video_stitcher_service.GetVodAdTagDetailRequest.serialize, + response_deserializer=ad_tag_details.VodAdTagDetail.deserialize, + ) + return self._stubs['get_vod_ad_tag_detail'] + + @property + def list_live_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListLiveAdTagDetailsRequest], + video_stitcher_service.ListLiveAdTagDetailsResponse]: + r"""Return a callable for the list live ad tag details method over gRPC. + + Return the list of ad tag details for the specified + live session. + + Returns: + Callable[[~.ListLiveAdTagDetailsRequest], + ~.ListLiveAdTagDetailsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_ad_tag_details' not in self._stubs: + self._stubs['list_live_ad_tag_details'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveAdTagDetails', + request_serializer=video_stitcher_service.ListLiveAdTagDetailsRequest.serialize, + response_deserializer=video_stitcher_service.ListLiveAdTagDetailsResponse.deserialize, + ) + return self._stubs['list_live_ad_tag_details'] + + @property + def get_live_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetLiveAdTagDetailRequest], + ad_tag_details.LiveAdTagDetail]: + r"""Return a callable for the get live ad tag detail method over gRPC. + + Returns the specified ad tag detail for the specified + live session. + + Returns: + Callable[[~.GetLiveAdTagDetailRequest], + ~.LiveAdTagDetail]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_ad_tag_detail' not in self._stubs: + self._stubs['get_live_ad_tag_detail'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveAdTagDetail', + request_serializer=video_stitcher_service.GetLiveAdTagDetailRequest.serialize, + response_deserializer=ad_tag_details.LiveAdTagDetail.deserialize, + ) + return self._stubs['get_live_ad_tag_detail'] + + @property + def create_slate(self) -> Callable[ + [video_stitcher_service.CreateSlateRequest], + operations_pb2.Operation]: + r"""Return a callable for the create slate method over gRPC. + + Creates a slate. + + Returns: + Callable[[~.CreateSlateRequest], + ~.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_slate' not in self._stubs: + self._stubs['create_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateSlate', + request_serializer=video_stitcher_service.CreateSlateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_slate'] + + @property + def list_slates(self) -> Callable[ + [video_stitcher_service.ListSlatesRequest], + video_stitcher_service.ListSlatesResponse]: + r"""Return a callable for the list slates method over gRPC. + + Lists all slates in the specified project and + location. + + Returns: + Callable[[~.ListSlatesRequest], + ~.ListSlatesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_slates' not in self._stubs: + self._stubs['list_slates'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListSlates', + request_serializer=video_stitcher_service.ListSlatesRequest.serialize, + response_deserializer=video_stitcher_service.ListSlatesResponse.deserialize, + ) + return self._stubs['list_slates'] + + @property + def get_slate(self) -> Callable[ + [video_stitcher_service.GetSlateRequest], + slates.Slate]: + r"""Return a callable for the get slate method over gRPC. + + Returns the specified slate. + + Returns: + Callable[[~.GetSlateRequest], + ~.Slate]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_slate' not in self._stubs: + self._stubs['get_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetSlate', + request_serializer=video_stitcher_service.GetSlateRequest.serialize, + response_deserializer=slates.Slate.deserialize, + ) + return self._stubs['get_slate'] + + @property + def update_slate(self) -> Callable[ + [video_stitcher_service.UpdateSlateRequest], + operations_pb2.Operation]: + r"""Return a callable for the update slate method over gRPC. + + Updates the specified slate. + + Returns: + Callable[[~.UpdateSlateRequest], + ~.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_slate' not in self._stubs: + self._stubs['update_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateSlate', + request_serializer=video_stitcher_service.UpdateSlateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_slate'] + + @property + def delete_slate(self) -> Callable[ + [video_stitcher_service.DeleteSlateRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete slate method over gRPC. + + Deletes the specified slate. + + Returns: + Callable[[~.DeleteSlateRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_slate' not in self._stubs: + self._stubs['delete_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteSlate', + request_serializer=video_stitcher_service.DeleteSlateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_slate'] + + @property + def create_live_session(self) -> Callable[ + [video_stitcher_service.CreateLiveSessionRequest], + sessions.LiveSession]: + r"""Return a callable for the create live session method over gRPC. + + Creates a new live session. + + Returns: + Callable[[~.CreateLiveSessionRequest], + ~.LiveSession]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_session' not in self._stubs: + self._stubs['create_live_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveSession', + request_serializer=video_stitcher_service.CreateLiveSessionRequest.serialize, + response_deserializer=sessions.LiveSession.deserialize, + ) + return self._stubs['create_live_session'] + + @property + def get_live_session(self) -> Callable[ + [video_stitcher_service.GetLiveSessionRequest], + sessions.LiveSession]: + r"""Return a callable for the get live session method over gRPC. + + Returns the details for the specified live session. + + Returns: + Callable[[~.GetLiveSessionRequest], + ~.LiveSession]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_session' not in self._stubs: + self._stubs['get_live_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveSession', + request_serializer=video_stitcher_service.GetLiveSessionRequest.serialize, + response_deserializer=sessions.LiveSession.deserialize, + ) + return self._stubs['get_live_session'] + + @property + def create_live_config(self) -> Callable[ + [video_stitcher_service.CreateLiveConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the create live config method over gRPC. + + Registers the live config with the provided unique ID + in the specified region. + + Returns: + Callable[[~.CreateLiveConfigRequest], + ~.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_live_config' not in self._stubs: + self._stubs['create_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveConfig', + request_serializer=video_stitcher_service.CreateLiveConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_live_config'] + + @property + def list_live_configs(self) -> Callable[ + [video_stitcher_service.ListLiveConfigsRequest], + video_stitcher_service.ListLiveConfigsResponse]: + r"""Return a callable for the list live configs method over gRPC. + + Lists all live configs managed by the Video Stitcher + that belong to the specified project and region. + + Returns: + Callable[[~.ListLiveConfigsRequest], + ~.ListLiveConfigsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_configs' not in self._stubs: + self._stubs['list_live_configs'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveConfigs', + request_serializer=video_stitcher_service.ListLiveConfigsRequest.serialize, + response_deserializer=video_stitcher_service.ListLiveConfigsResponse.deserialize, + ) + return self._stubs['list_live_configs'] + + @property + def get_live_config(self) -> Callable[ + [video_stitcher_service.GetLiveConfigRequest], + live_configs.LiveConfig]: + r"""Return a callable for the get live config method over gRPC. + + Returns the specified live config managed by the + Video Stitcher service. + + Returns: + Callable[[~.GetLiveConfigRequest], + ~.LiveConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_config' not in self._stubs: + self._stubs['get_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveConfig', + request_serializer=video_stitcher_service.GetLiveConfigRequest.serialize, + response_deserializer=live_configs.LiveConfig.deserialize, + ) + return self._stubs['get_live_config'] + + @property + def delete_live_config(self) -> Callable[ + [video_stitcher_service.DeleteLiveConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete live config method over gRPC. + + Deletes the specified live config. + + Returns: + Callable[[~.DeleteLiveConfigRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_live_config' not in self._stubs: + self._stubs['delete_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteLiveConfig', + request_serializer=video_stitcher_service.DeleteLiveConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_live_config'] + + @property + def update_live_config(self) -> Callable[ + [video_stitcher_service.UpdateLiveConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the update live config method over gRPC. + + Updates the specified LiveConfig. Only update fields + specified in the call method body. + + Returns: + Callable[[~.UpdateLiveConfigRequest], + ~.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_live_config' not in self._stubs: + self._stubs['update_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateLiveConfig', + request_serializer=video_stitcher_service.UpdateLiveConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_live_config'] + + @property + def create_vod_config(self) -> Callable[ + [video_stitcher_service.CreateVodConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the create vod config method over gRPC. + + Registers the VOD config with the provided unique ID + in the specified region. + + Returns: + Callable[[~.CreateVodConfigRequest], + ~.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_vod_config' not in self._stubs: + self._stubs['create_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodConfig', + request_serializer=video_stitcher_service.CreateVodConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_vod_config'] + + @property + def list_vod_configs(self) -> Callable[ + [video_stitcher_service.ListVodConfigsRequest], + video_stitcher_service.ListVodConfigsResponse]: + r"""Return a callable for the list vod configs method over gRPC. + + Lists all VOD configs managed by the Video Stitcher + API that belong to the specified project and region. + + Returns: + Callable[[~.ListVodConfigsRequest], + ~.ListVodConfigsResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_configs' not in self._stubs: + self._stubs['list_vod_configs'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodConfigs', + request_serializer=video_stitcher_service.ListVodConfigsRequest.serialize, + response_deserializer=video_stitcher_service.ListVodConfigsResponse.deserialize, + ) + return self._stubs['list_vod_configs'] + + @property + def get_vod_config(self) -> Callable[ + [video_stitcher_service.GetVodConfigRequest], + vod_configs.VodConfig]: + r"""Return a callable for the get vod config method over gRPC. + + Returns the specified VOD config managed by the Video + Stitcher API service. + + Returns: + Callable[[~.GetVodConfigRequest], + ~.VodConfig]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_config' not in self._stubs: + self._stubs['get_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodConfig', + request_serializer=video_stitcher_service.GetVodConfigRequest.serialize, + response_deserializer=vod_configs.VodConfig.deserialize, + ) + return self._stubs['get_vod_config'] + + @property + def delete_vod_config(self) -> Callable[ + [video_stitcher_service.DeleteVodConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the delete vod config method over gRPC. + + Deletes the specified VOD config. + + Returns: + Callable[[~.DeleteVodConfigRequest], + ~.Operation]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_vod_config' not in self._stubs: + self._stubs['delete_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteVodConfig', + request_serializer=video_stitcher_service.DeleteVodConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_vod_config'] + + @property + def update_vod_config(self) -> Callable[ + [video_stitcher_service.UpdateVodConfigRequest], + operations_pb2.Operation]: + r"""Return a callable for the update vod config method over gRPC. + + Updates the specified VOD config. Only update fields + specified in the call method body. + + Returns: + Callable[[~.UpdateVodConfigRequest], + ~.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_vod_config' not in self._stubs: + self._stubs['update_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateVodConfig', + request_serializer=video_stitcher_service.UpdateVodConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_vod_config'] + + def close(self): + self._logged_channel.close() + + @property + def delete_operation( + self, + ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: + r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: + self._stubs["delete_operation"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/DeleteOperation", + request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["delete_operation"] + + @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._logged_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._logged_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._logged_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'VideoStitcherServiceGrpcTransport', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py new file mode 100644 index 000000000000..f94216db29d5 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py @@ -0,0 +1,1408 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 inspect +import json +import pickle +import logging as std_logging +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 exceptions as core_exceptions +from google.api_core import retry_async as retries +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 +from google.protobuf.json_format import MessageToJson +import google.protobuf.message + +import grpc # type: ignore +import proto # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore +from .base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO +from .grpc import VideoStitcherServiceGrpcTransport + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor(grpc.aio.UnaryUnaryClientInterceptor): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + + +class VideoStitcherServiceGrpcAsyncIOTransport(VideoStitcherServiceTransport): + """gRPC AsyncIO backend transport for VideoStitcherService. + + Video-On-Demand content stitching API allows you to insert + ads into (VoD) video on demand files. You will be able to render + custom scrubber bars with highlighted ads, enforce ad policies, + allow seamless playback and tracking on native players and + monetize content with any standard VMAP compliant ad server. + + 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 = 'videostitcher.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`. + 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 = 'videostitcher.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[Union[aio.Channel, Callable[..., 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 (default: 'videostitcher.googleapis.com'). + 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 a ``channel`` instance 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 a ``channel`` instance 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[Union[aio.Channel, Callable[..., aio.Channel]]]): + A ``Channel`` instance through which to make calls, or a Callable + that constructs and returns one. If set to None, ``self.create_channel`` + is used to create the channel. If a Callable is given, it will be called + with the same arguments as used in ``self.create_channel``. + 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 a ``channel`` instance 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 a ``channel`` instance 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 isinstance(channel, aio.Channel): + # Ignore credentials if a channel was passed. + credentials = None + self._ignore_credentials = True + # 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: + # initialize with the provided callable or the default channel + channel_init = channel or type(self).create_channel + self._grpc_channel = channel_init( + 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), + ], + ) + + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel + self._wrap_with_kind = "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters + # Wrap messages. This must be done after self._logged_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._logged_channel + ) + + # Return the client from cache. + return self._operations_client + + @property + def create_cdn_key(self) -> Callable[ + [video_stitcher_service.CreateCdnKeyRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create cdn key method over gRPC. + + Creates a new CDN key. + + Returns: + Callable[[~.CreateCdnKeyRequest], + 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_cdn_key' not in self._stubs: + self._stubs['create_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateCdnKey', + request_serializer=video_stitcher_service.CreateCdnKeyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_cdn_key'] + + @property + def list_cdn_keys(self) -> Callable[ + [video_stitcher_service.ListCdnKeysRequest], + Awaitable[video_stitcher_service.ListCdnKeysResponse]]: + r"""Return a callable for the list cdn keys method over gRPC. + + Lists all CDN keys in the specified project and + location. + + Returns: + Callable[[~.ListCdnKeysRequest], + Awaitable[~.ListCdnKeysResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_cdn_keys' not in self._stubs: + self._stubs['list_cdn_keys'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListCdnKeys', + request_serializer=video_stitcher_service.ListCdnKeysRequest.serialize, + response_deserializer=video_stitcher_service.ListCdnKeysResponse.deserialize, + ) + return self._stubs['list_cdn_keys'] + + @property + def get_cdn_key(self) -> Callable[ + [video_stitcher_service.GetCdnKeyRequest], + Awaitable[cdn_keys.CdnKey]]: + r"""Return a callable for the get cdn key method over gRPC. + + Returns the specified CDN key. + + Returns: + Callable[[~.GetCdnKeyRequest], + Awaitable[~.CdnKey]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_cdn_key' not in self._stubs: + self._stubs['get_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetCdnKey', + request_serializer=video_stitcher_service.GetCdnKeyRequest.serialize, + response_deserializer=cdn_keys.CdnKey.deserialize, + ) + return self._stubs['get_cdn_key'] + + @property + def delete_cdn_key(self) -> Callable[ + [video_stitcher_service.DeleteCdnKeyRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete cdn key method over gRPC. + + Deletes the specified CDN key. + + Returns: + Callable[[~.DeleteCdnKeyRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_cdn_key' not in self._stubs: + self._stubs['delete_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteCdnKey', + request_serializer=video_stitcher_service.DeleteCdnKeyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_cdn_key'] + + @property + def update_cdn_key(self) -> Callable[ + [video_stitcher_service.UpdateCdnKeyRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update cdn key method over gRPC. + + Updates the specified CDN key. Only update fields + specified in the call method body. + + Returns: + Callable[[~.UpdateCdnKeyRequest], + 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_cdn_key' not in self._stubs: + self._stubs['update_cdn_key'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateCdnKey', + request_serializer=video_stitcher_service.UpdateCdnKeyRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_cdn_key'] + + @property + def create_vod_session(self) -> Callable[ + [video_stitcher_service.CreateVodSessionRequest], + Awaitable[sessions.VodSession]]: + r"""Return a callable for the create vod session method over gRPC. + + Creates a client side playback VOD session and + returns the full tracking and playback metadata of the + session. + + Returns: + Callable[[~.CreateVodSessionRequest], + Awaitable[~.VodSession]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_session' not in self._stubs: + self._stubs['create_vod_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodSession', + request_serializer=video_stitcher_service.CreateVodSessionRequest.serialize, + response_deserializer=sessions.VodSession.deserialize, + ) + return self._stubs['create_vod_session'] + + @property + def get_vod_session(self) -> Callable[ + [video_stitcher_service.GetVodSessionRequest], + Awaitable[sessions.VodSession]]: + r"""Return a callable for the get vod session method over gRPC. + + Returns the full tracking, playback metadata, and + relevant ad-ops logs for the specified VOD session. + + Returns: + Callable[[~.GetVodSessionRequest], + Awaitable[~.VodSession]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_session' not in self._stubs: + self._stubs['get_vod_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodSession', + request_serializer=video_stitcher_service.GetVodSessionRequest.serialize, + response_deserializer=sessions.VodSession.deserialize, + ) + return self._stubs['get_vod_session'] + + @property + def list_vod_stitch_details(self) -> Callable[ + [video_stitcher_service.ListVodStitchDetailsRequest], + Awaitable[video_stitcher_service.ListVodStitchDetailsResponse]]: + r"""Return a callable for the list vod stitch details method over gRPC. + + Returns a list of detailed stitching information of + the specified VOD session. + + Returns: + Callable[[~.ListVodStitchDetailsRequest], + Awaitable[~.ListVodStitchDetailsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_stitch_details' not in self._stubs: + self._stubs['list_vod_stitch_details'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodStitchDetails', + request_serializer=video_stitcher_service.ListVodStitchDetailsRequest.serialize, + response_deserializer=video_stitcher_service.ListVodStitchDetailsResponse.deserialize, + ) + return self._stubs['list_vod_stitch_details'] + + @property + def get_vod_stitch_detail(self) -> Callable[ + [video_stitcher_service.GetVodStitchDetailRequest], + Awaitable[stitch_details.VodStitchDetail]]: + r"""Return a callable for the get vod stitch detail method over gRPC. + + Returns the specified stitching information for the + specified VOD session. + + Returns: + Callable[[~.GetVodStitchDetailRequest], + Awaitable[~.VodStitchDetail]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_stitch_detail' not in self._stubs: + self._stubs['get_vod_stitch_detail'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodStitchDetail', + request_serializer=video_stitcher_service.GetVodStitchDetailRequest.serialize, + response_deserializer=stitch_details.VodStitchDetail.deserialize, + ) + return self._stubs['get_vod_stitch_detail'] + + @property + def list_vod_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListVodAdTagDetailsRequest], + Awaitable[video_stitcher_service.ListVodAdTagDetailsResponse]]: + r"""Return a callable for the list vod ad tag details method over gRPC. + + Return the list of ad tag details for the specified + VOD session. + + Returns: + Callable[[~.ListVodAdTagDetailsRequest], + Awaitable[~.ListVodAdTagDetailsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_ad_tag_details' not in self._stubs: + self._stubs['list_vod_ad_tag_details'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodAdTagDetails', + request_serializer=video_stitcher_service.ListVodAdTagDetailsRequest.serialize, + response_deserializer=video_stitcher_service.ListVodAdTagDetailsResponse.deserialize, + ) + return self._stubs['list_vod_ad_tag_details'] + + @property + def get_vod_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetVodAdTagDetailRequest], + Awaitable[ad_tag_details.VodAdTagDetail]]: + r"""Return a callable for the get vod ad tag detail method over gRPC. + + Returns the specified ad tag detail for the specified + VOD session. + + Returns: + Callable[[~.GetVodAdTagDetailRequest], + Awaitable[~.VodAdTagDetail]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_ad_tag_detail' not in self._stubs: + self._stubs['get_vod_ad_tag_detail'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodAdTagDetail', + request_serializer=video_stitcher_service.GetVodAdTagDetailRequest.serialize, + response_deserializer=ad_tag_details.VodAdTagDetail.deserialize, + ) + return self._stubs['get_vod_ad_tag_detail'] + + @property + def list_live_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListLiveAdTagDetailsRequest], + Awaitable[video_stitcher_service.ListLiveAdTagDetailsResponse]]: + r"""Return a callable for the list live ad tag details method over gRPC. + + Return the list of ad tag details for the specified + live session. + + Returns: + Callable[[~.ListLiveAdTagDetailsRequest], + Awaitable[~.ListLiveAdTagDetailsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_ad_tag_details' not in self._stubs: + self._stubs['list_live_ad_tag_details'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveAdTagDetails', + request_serializer=video_stitcher_service.ListLiveAdTagDetailsRequest.serialize, + response_deserializer=video_stitcher_service.ListLiveAdTagDetailsResponse.deserialize, + ) + return self._stubs['list_live_ad_tag_details'] + + @property + def get_live_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetLiveAdTagDetailRequest], + Awaitable[ad_tag_details.LiveAdTagDetail]]: + r"""Return a callable for the get live ad tag detail method over gRPC. + + Returns the specified ad tag detail for the specified + live session. + + Returns: + Callable[[~.GetLiveAdTagDetailRequest], + Awaitable[~.LiveAdTagDetail]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_ad_tag_detail' not in self._stubs: + self._stubs['get_live_ad_tag_detail'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveAdTagDetail', + request_serializer=video_stitcher_service.GetLiveAdTagDetailRequest.serialize, + response_deserializer=ad_tag_details.LiveAdTagDetail.deserialize, + ) + return self._stubs['get_live_ad_tag_detail'] + + @property + def create_slate(self) -> Callable[ + [video_stitcher_service.CreateSlateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create slate method over gRPC. + + Creates a slate. + + Returns: + Callable[[~.CreateSlateRequest], + 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_slate' not in self._stubs: + self._stubs['create_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateSlate', + request_serializer=video_stitcher_service.CreateSlateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_slate'] + + @property + def list_slates(self) -> Callable[ + [video_stitcher_service.ListSlatesRequest], + Awaitable[video_stitcher_service.ListSlatesResponse]]: + r"""Return a callable for the list slates method over gRPC. + + Lists all slates in the specified project and + location. + + Returns: + Callable[[~.ListSlatesRequest], + Awaitable[~.ListSlatesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_slates' not in self._stubs: + self._stubs['list_slates'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListSlates', + request_serializer=video_stitcher_service.ListSlatesRequest.serialize, + response_deserializer=video_stitcher_service.ListSlatesResponse.deserialize, + ) + return self._stubs['list_slates'] + + @property + def get_slate(self) -> Callable[ + [video_stitcher_service.GetSlateRequest], + Awaitable[slates.Slate]]: + r"""Return a callable for the get slate method over gRPC. + + Returns the specified slate. + + Returns: + Callable[[~.GetSlateRequest], + Awaitable[~.Slate]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_slate' not in self._stubs: + self._stubs['get_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetSlate', + request_serializer=video_stitcher_service.GetSlateRequest.serialize, + response_deserializer=slates.Slate.deserialize, + ) + return self._stubs['get_slate'] + + @property + def update_slate(self) -> Callable[ + [video_stitcher_service.UpdateSlateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update slate method over gRPC. + + Updates the specified slate. + + Returns: + Callable[[~.UpdateSlateRequest], + 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_slate' not in self._stubs: + self._stubs['update_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateSlate', + request_serializer=video_stitcher_service.UpdateSlateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_slate'] + + @property + def delete_slate(self) -> Callable[ + [video_stitcher_service.DeleteSlateRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete slate method over gRPC. + + Deletes the specified slate. + + Returns: + Callable[[~.DeleteSlateRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_slate' not in self._stubs: + self._stubs['delete_slate'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteSlate', + request_serializer=video_stitcher_service.DeleteSlateRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_slate'] + + @property + def create_live_session(self) -> Callable[ + [video_stitcher_service.CreateLiveSessionRequest], + Awaitable[sessions.LiveSession]]: + r"""Return a callable for the create live session method over gRPC. + + Creates a new live session. + + Returns: + Callable[[~.CreateLiveSessionRequest], + Awaitable[~.LiveSession]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_session' not in self._stubs: + self._stubs['create_live_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveSession', + request_serializer=video_stitcher_service.CreateLiveSessionRequest.serialize, + response_deserializer=sessions.LiveSession.deserialize, + ) + return self._stubs['create_live_session'] + + @property + def get_live_session(self) -> Callable[ + [video_stitcher_service.GetLiveSessionRequest], + Awaitable[sessions.LiveSession]]: + r"""Return a callable for the get live session method over gRPC. + + Returns the details for the specified live session. + + Returns: + Callable[[~.GetLiveSessionRequest], + Awaitable[~.LiveSession]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_session' not in self._stubs: + self._stubs['get_live_session'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveSession', + request_serializer=video_stitcher_service.GetLiveSessionRequest.serialize, + response_deserializer=sessions.LiveSession.deserialize, + ) + return self._stubs['get_live_session'] + + @property + def create_live_config(self) -> Callable[ + [video_stitcher_service.CreateLiveConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create live config method over gRPC. + + Registers the live config with the provided unique ID + in the specified region. + + Returns: + Callable[[~.CreateLiveConfigRequest], + 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_live_config' not in self._stubs: + self._stubs['create_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveConfig', + request_serializer=video_stitcher_service.CreateLiveConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_live_config'] + + @property + def list_live_configs(self) -> Callable[ + [video_stitcher_service.ListLiveConfigsRequest], + Awaitable[video_stitcher_service.ListLiveConfigsResponse]]: + r"""Return a callable for the list live configs method over gRPC. + + Lists all live configs managed by the Video Stitcher + that belong to the specified project and region. + + Returns: + Callable[[~.ListLiveConfigsRequest], + Awaitable[~.ListLiveConfigsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_configs' not in self._stubs: + self._stubs['list_live_configs'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveConfigs', + request_serializer=video_stitcher_service.ListLiveConfigsRequest.serialize, + response_deserializer=video_stitcher_service.ListLiveConfigsResponse.deserialize, + ) + return self._stubs['list_live_configs'] + + @property + def get_live_config(self) -> Callable[ + [video_stitcher_service.GetLiveConfigRequest], + Awaitable[live_configs.LiveConfig]]: + r"""Return a callable for the get live config method over gRPC. + + Returns the specified live config managed by the + Video Stitcher service. + + Returns: + Callable[[~.GetLiveConfigRequest], + Awaitable[~.LiveConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_live_config' not in self._stubs: + self._stubs['get_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveConfig', + request_serializer=video_stitcher_service.GetLiveConfigRequest.serialize, + response_deserializer=live_configs.LiveConfig.deserialize, + ) + return self._stubs['get_live_config'] + + @property + def delete_live_config(self) -> Callable[ + [video_stitcher_service.DeleteLiveConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete live config method over gRPC. + + Deletes the specified live config. + + Returns: + Callable[[~.DeleteLiveConfigRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_live_config' not in self._stubs: + self._stubs['delete_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteLiveConfig', + request_serializer=video_stitcher_service.DeleteLiveConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_live_config'] + + @property + def update_live_config(self) -> Callable[ + [video_stitcher_service.UpdateLiveConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update live config method over gRPC. + + Updates the specified LiveConfig. Only update fields + specified in the call method body. + + Returns: + Callable[[~.UpdateLiveConfigRequest], + 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_live_config' not in self._stubs: + self._stubs['update_live_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateLiveConfig', + request_serializer=video_stitcher_service.UpdateLiveConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_live_config'] + + @property + def create_vod_config(self) -> Callable[ + [video_stitcher_service.CreateVodConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the create vod config method over gRPC. + + Registers the VOD config with the provided unique ID + in the specified region. + + Returns: + Callable[[~.CreateVodConfigRequest], + 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_vod_config' not in self._stubs: + self._stubs['create_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodConfig', + request_serializer=video_stitcher_service.CreateVodConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['create_vod_config'] + + @property + def list_vod_configs(self) -> Callable[ + [video_stitcher_service.ListVodConfigsRequest], + Awaitable[video_stitcher_service.ListVodConfigsResponse]]: + r"""Return a callable for the list vod configs method over gRPC. + + Lists all VOD configs managed by the Video Stitcher + API that belong to the specified project and region. + + Returns: + Callable[[~.ListVodConfigsRequest], + Awaitable[~.ListVodConfigsResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_configs' not in self._stubs: + self._stubs['list_vod_configs'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodConfigs', + request_serializer=video_stitcher_service.ListVodConfigsRequest.serialize, + response_deserializer=video_stitcher_service.ListVodConfigsResponse.deserialize, + ) + return self._stubs['list_vod_configs'] + + @property + def get_vod_config(self) -> Callable[ + [video_stitcher_service.GetVodConfigRequest], + Awaitable[vod_configs.VodConfig]]: + r"""Return a callable for the get vod config method over gRPC. + + Returns the specified VOD config managed by the Video + Stitcher API service. + + Returns: + Callable[[~.GetVodConfigRequest], + Awaitable[~.VodConfig]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-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_vod_config' not in self._stubs: + self._stubs['get_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodConfig', + request_serializer=video_stitcher_service.GetVodConfigRequest.serialize, + response_deserializer=vod_configs.VodConfig.deserialize, + ) + return self._stubs['get_vod_config'] + + @property + def delete_vod_config(self) -> Callable[ + [video_stitcher_service.DeleteVodConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the delete vod config method over gRPC. + + Deletes the specified VOD config. + + Returns: + Callable[[~.DeleteVodConfigRequest], + Awaitable[~.Operation]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if 'delete_vod_config' not in self._stubs: + self._stubs['delete_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteVodConfig', + request_serializer=video_stitcher_service.DeleteVodConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['delete_vod_config'] + + @property + def update_vod_config(self) -> Callable[ + [video_stitcher_service.UpdateVodConfigRequest], + Awaitable[operations_pb2.Operation]]: + r"""Return a callable for the update vod config method over gRPC. + + Updates the specified VOD config. Only update fields + specified in the call method body. + + Returns: + Callable[[~.UpdateVodConfigRequest], + 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_vod_config' not in self._stubs: + self._stubs['update_vod_config'] = self._logged_channel.unary_unary( + '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateVodConfig', + request_serializer=video_stitcher_service.UpdateVodConfigRequest.serialize, + response_deserializer=operations_pb2.Operation.FromString, + ) + return self._stubs['update_vod_config'] + + def _prep_wrapped_messages(self, client_info): + """ Precompute the wrapped methods, overriding the base class method to use async wrappers.""" + self._wrapped_methods = { + self.create_cdn_key: self._wrap_method( + self.create_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.list_cdn_keys: self._wrap_method( + self.list_cdn_keys, + default_timeout=60.0, + client_info=client_info, + ), + self.get_cdn_key: self._wrap_method( + self.get_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_cdn_key: self._wrap_method( + self.delete_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.update_cdn_key: self._wrap_method( + self.update_cdn_key, + default_timeout=60.0, + client_info=client_info, + ), + self.create_vod_session: self._wrap_method( + self.create_vod_session, + default_timeout=60.0, + client_info=client_info, + ), + self.get_vod_session: self._wrap_method( + self.get_vod_session, + default_timeout=60.0, + client_info=client_info, + ), + self.list_vod_stitch_details: self._wrap_method( + self.list_vod_stitch_details, + default_timeout=60.0, + client_info=client_info, + ), + self.get_vod_stitch_detail: self._wrap_method( + self.get_vod_stitch_detail, + default_timeout=60.0, + client_info=client_info, + ), + self.list_vod_ad_tag_details: self._wrap_method( + self.list_vod_ad_tag_details, + default_timeout=60.0, + client_info=client_info, + ), + self.get_vod_ad_tag_detail: self._wrap_method( + self.get_vod_ad_tag_detail, + default_timeout=60.0, + client_info=client_info, + ), + self.list_live_ad_tag_details: self._wrap_method( + self.list_live_ad_tag_details, + default_timeout=60.0, + client_info=client_info, + ), + self.get_live_ad_tag_detail: self._wrap_method( + self.get_live_ad_tag_detail, + default_timeout=60.0, + client_info=client_info, + ), + self.create_slate: self._wrap_method( + self.create_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.list_slates: self._wrap_method( + self.list_slates, + default_timeout=60.0, + client_info=client_info, + ), + self.get_slate: self._wrap_method( + self.get_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.update_slate: self._wrap_method( + self.update_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_slate: self._wrap_method( + self.delete_slate, + default_timeout=60.0, + client_info=client_info, + ), + self.create_live_session: self._wrap_method( + self.create_live_session, + default_timeout=60.0, + client_info=client_info, + ), + self.get_live_session: self._wrap_method( + self.get_live_session, + default_timeout=60.0, + client_info=client_info, + ), + self.create_live_config: self._wrap_method( + self.create_live_config, + default_timeout=60.0, + client_info=client_info, + ), + self.list_live_configs: self._wrap_method( + self.list_live_configs, + default_timeout=60.0, + client_info=client_info, + ), + self.get_live_config: self._wrap_method( + self.get_live_config, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_live_config: self._wrap_method( + self.delete_live_config, + default_timeout=60.0, + client_info=client_info, + ), + self.update_live_config: self._wrap_method( + self.update_live_config, + default_timeout=None, + client_info=client_info, + ), + self.create_vod_config: self._wrap_method( + self.create_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.list_vod_configs: self._wrap_method( + self.list_vod_configs, + default_timeout=None, + client_info=client_info, + ), + self.get_vod_config: self._wrap_method( + self.get_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.delete_vod_config: self._wrap_method( + self.delete_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.update_vod_config: self._wrap_method( + self.update_vod_config, + default_timeout=None, + client_info=client_info, + ), + self.cancel_operation: self._wrap_method( + self.cancel_operation, + default_timeout=None, + client_info=client_info, + ), + self.delete_operation: self._wrap_method( + self.delete_operation, + default_timeout=None, + client_info=client_info, + ), + self.get_operation: self._wrap_method( + self.get_operation, + default_timeout=None, + client_info=client_info, + ), + self.list_operations: self._wrap_method( + self.list_operations, + default_timeout=None, + client_info=client_info, + ), + } + + def _wrap_method(self, func, *args, **kwargs): + if self._wrap_with_kind: # pragma: NO COVER + kwargs["kind"] = self.kind + return gapic_v1.method_async.wrap_method(func, *args, **kwargs) + + def close(self): + return self._logged_channel.close() + + @property + def kind(self) -> str: + return "grpc_asyncio" + + @property + def delete_operation( + self, + ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: + r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: + self._stubs["delete_operation"] = self._logged_channel.unary_unary( + "/google.longrunning.Operations/DeleteOperation", + request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, + response_deserializer=None, + ) + return self._stubs["delete_operation"] + + @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._logged_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._logged_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._logged_channel.unary_unary( + "/google.longrunning.Operations/ListOperations", + request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, + response_deserializer=operations_pb2.ListOperationsResponse.FromString, + ) + return self._stubs["list_operations"] + + +__all__ = ( + 'VideoStitcherServiceGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py new file mode 100644 index 000000000000..34ecf213f3ae --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py @@ -0,0 +1,6004 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 logging +import json # type: ignore + +from google.auth.transport.requests import AuthorizedSession # 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 gapic_v1 +import google.protobuf + +from google.protobuf import json_format +from google.api_core import operations_v1 + +from requests import __version__ as requests_version +import dataclasses +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union +import warnings + + +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore + + +from .rest_base import _BaseVideoStitcherServiceRestTransport +from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object, None] # type: ignore + +try: + from google.api_core import client_logging # type: ignore + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, + grpc_version=None, + rest_version=f"requests@{requests_version}", +) + +if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER + DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ + + +class VideoStitcherServiceRestInterceptor: + """Interceptor for VideoStitcherService. + + 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 VideoStitcherServiceRestTransport. + + .. code-block:: python + class MyCustomVideoStitcherServiceInterceptor(VideoStitcherServiceRestInterceptor): + def pre_create_cdn_key(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_cdn_key(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_live_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_live_session(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_live_session(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_slate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_slate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_vod_session(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_vod_session(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_cdn_key(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_cdn_key(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_live_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_slate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_slate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_cdn_key(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_cdn_key(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_live_ad_tag_detail(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_live_ad_tag_detail(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_live_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_live_session(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_live_session(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_slate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_slate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_vod_ad_tag_detail(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_vod_ad_tag_detail(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_vod_session(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_vod_session(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_vod_stitch_detail(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_vod_stitch_detail(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_cdn_keys(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_cdn_keys(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_live_ad_tag_details(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_live_ad_tag_details(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_live_configs(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_live_configs(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_slates(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_slates(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_vod_ad_tag_details(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_vod_ad_tag_details(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_vod_configs(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_vod_configs(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_vod_stitch_details(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_vod_stitch_details(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_cdn_key(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_cdn_key(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_live_config(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_slate(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_slate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + + transport = VideoStitcherServiceRestTransport(interceptor=MyCustomVideoStitcherServiceInterceptor()) + client = VideoStitcherServiceClient(transport=transport) + + + """ + def pre_create_cdn_key(self, request: video_stitcher_service.CreateCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_cdn_key + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_cdn_key(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_cdn_key + + DEPRECATED. Please use the `post_create_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_cdn_key` interceptor runs + before the `post_create_cdn_key_with_metadata` interceptor. + """ + return response + + def post_create_cdn_key_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_cdn_key_with_metadata` + interceptor in new development instead of the `post_create_cdn_key` interceptor. + When both interceptors are used, this `post_create_cdn_key_with_metadata` interceptor runs after the + `post_create_cdn_key` interceptor. The (possibly modified) response returned by + `post_create_cdn_key` will be passed to + `post_create_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_create_live_config(self, request: video_stitcher_service.CreateLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_live_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_live_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_live_config + + DEPRECATED. Please use the `post_create_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_live_config` interceptor runs + before the `post_create_live_config_with_metadata` interceptor. + """ + return response + + def post_create_live_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_live_config_with_metadata` + interceptor in new development instead of the `post_create_live_config` interceptor. + When both interceptors are used, this `post_create_live_config_with_metadata` interceptor runs after the + `post_create_live_config` interceptor. The (possibly modified) response returned by + `post_create_live_config` will be passed to + `post_create_live_config_with_metadata`. + """ + return response, metadata + + def pre_create_live_session(self, request: video_stitcher_service.CreateLiveSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateLiveSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_live_session + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_live_session(self, response: sessions.LiveSession) -> sessions.LiveSession: + """Post-rpc interceptor for create_live_session + + DEPRECATED. Please use the `post_create_live_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_live_session` interceptor runs + before the `post_create_live_session_with_metadata` interceptor. + """ + return response + + def post_create_live_session_with_metadata(self, response: sessions.LiveSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.LiveSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_live_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_live_session_with_metadata` + interceptor in new development instead of the `post_create_live_session` interceptor. + When both interceptors are used, this `post_create_live_session_with_metadata` interceptor runs after the + `post_create_live_session` interceptor. The (possibly modified) response returned by + `post_create_live_session` will be passed to + `post_create_live_session_with_metadata`. + """ + return response, metadata + + def pre_create_slate(self, request: video_stitcher_service.CreateSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_slate + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_slate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_slate + + DEPRECATED. Please use the `post_create_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_slate` interceptor runs + before the `post_create_slate_with_metadata` interceptor. + """ + return response + + def post_create_slate_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_slate + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_slate_with_metadata` + interceptor in new development instead of the `post_create_slate` interceptor. + When both interceptors are used, this `post_create_slate_with_metadata` interceptor runs after the + `post_create_slate` interceptor. The (possibly modified) response returned by + `post_create_slate` will be passed to + `post_create_slate_with_metadata`. + """ + return response, metadata + + def pre_create_vod_config(self, request: video_stitcher_service.CreateVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_vod_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_vod_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for create_vod_config + + DEPRECATED. Please use the `post_create_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_vod_config` interceptor runs + before the `post_create_vod_config_with_metadata` interceptor. + """ + return response + + def post_create_vod_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_vod_config_with_metadata` + interceptor in new development instead of the `post_create_vod_config` interceptor. + When both interceptors are used, this `post_create_vod_config_with_metadata` interceptor runs after the + `post_create_vod_config` interceptor. The (possibly modified) response returned by + `post_create_vod_config` will be passed to + `post_create_vod_config_with_metadata`. + """ + return response, metadata + + def pre_create_vod_session(self, request: video_stitcher_service.CreateVodSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateVodSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for create_vod_session + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_vod_session(self, response: sessions.VodSession) -> sessions.VodSession: + """Post-rpc interceptor for create_vod_session + + DEPRECATED. Please use the `post_create_vod_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_vod_session` interceptor runs + before the `post_create_vod_session_with_metadata` interceptor. + """ + return response + + def post_create_vod_session_with_metadata(self, response: sessions.VodSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.VodSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_vod_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_vod_session_with_metadata` + interceptor in new development instead of the `post_create_vod_session` interceptor. + When both interceptors are used, this `post_create_vod_session_with_metadata` interceptor runs after the + `post_create_vod_session` interceptor. The (possibly modified) response returned by + `post_create_vod_session` will be passed to + `post_create_vod_session_with_metadata`. + """ + return response, metadata + + def pre_delete_cdn_key(self, request: video_stitcher_service.DeleteCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_cdn_key + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_delete_cdn_key(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_cdn_key + + DEPRECATED. Please use the `post_delete_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_delete_cdn_key` interceptor runs + before the `post_delete_cdn_key_with_metadata` interceptor. + """ + return response + + def post_delete_cdn_key_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_cdn_key_with_metadata` + interceptor in new development instead of the `post_delete_cdn_key` interceptor. + When both interceptors are used, this `post_delete_cdn_key_with_metadata` interceptor runs after the + `post_delete_cdn_key` interceptor. The (possibly modified) response returned by + `post_delete_cdn_key` will be passed to + `post_delete_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_delete_live_config(self, request: video_stitcher_service.DeleteLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_live_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_delete_live_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_live_config + + DEPRECATED. Please use the `post_delete_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_delete_live_config` interceptor runs + before the `post_delete_live_config_with_metadata` interceptor. + """ + return response + + def post_delete_live_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_live_config_with_metadata` + interceptor in new development instead of the `post_delete_live_config` interceptor. + When both interceptors are used, this `post_delete_live_config_with_metadata` interceptor runs after the + `post_delete_live_config` interceptor. The (possibly modified) response returned by + `post_delete_live_config` will be passed to + `post_delete_live_config_with_metadata`. + """ + return response, metadata + + def pre_delete_slate(self, request: video_stitcher_service.DeleteSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_slate + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_delete_slate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_slate + + DEPRECATED. Please use the `post_delete_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_delete_slate` interceptor runs + before the `post_delete_slate_with_metadata` interceptor. + """ + return response + + def post_delete_slate_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_slate + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_slate_with_metadata` + interceptor in new development instead of the `post_delete_slate` interceptor. + When both interceptors are used, this `post_delete_slate_with_metadata` interceptor runs after the + `post_delete_slate` interceptor. The (possibly modified) response returned by + `post_delete_slate` will be passed to + `post_delete_slate_with_metadata`. + """ + return response, metadata + + def pre_delete_vod_config(self, request: video_stitcher_service.DeleteVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_vod_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_delete_vod_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_vod_config + + DEPRECATED. Please use the `post_delete_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_delete_vod_config` interceptor runs + before the `post_delete_vod_config_with_metadata` interceptor. + """ + return response + + def post_delete_vod_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_vod_config_with_metadata` + interceptor in new development instead of the `post_delete_vod_config` interceptor. + When both interceptors are used, this `post_delete_vod_config_with_metadata` interceptor runs after the + `post_delete_vod_config` interceptor. The (possibly modified) response returned by + `post_delete_vod_config` will be passed to + `post_delete_vod_config_with_metadata`. + """ + return response, metadata + + def pre_get_cdn_key(self, request: video_stitcher_service.GetCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_cdn_key + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_cdn_key(self, response: cdn_keys.CdnKey) -> cdn_keys.CdnKey: + """Post-rpc interceptor for get_cdn_key + + DEPRECATED. Please use the `post_get_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_cdn_key` interceptor runs + before the `post_get_cdn_key_with_metadata` interceptor. + """ + return response + + def post_get_cdn_key_with_metadata(self, response: cdn_keys.CdnKey, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cdn_keys.CdnKey, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_cdn_key_with_metadata` + interceptor in new development instead of the `post_get_cdn_key` interceptor. + When both interceptors are used, this `post_get_cdn_key_with_metadata` interceptor runs after the + `post_get_cdn_key` interceptor. The (possibly modified) response returned by + `post_get_cdn_key` will be passed to + `post_get_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_get_live_ad_tag_detail(self, request: video_stitcher_service.GetLiveAdTagDetailRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetLiveAdTagDetailRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_live_ad_tag_detail + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_live_ad_tag_detail(self, response: ad_tag_details.LiveAdTagDetail) -> ad_tag_details.LiveAdTagDetail: + """Post-rpc interceptor for get_live_ad_tag_detail + + DEPRECATED. Please use the `post_get_live_ad_tag_detail_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_live_ad_tag_detail` interceptor runs + before the `post_get_live_ad_tag_detail_with_metadata` interceptor. + """ + return response + + def post_get_live_ad_tag_detail_with_metadata(self, response: ad_tag_details.LiveAdTagDetail, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[ad_tag_details.LiveAdTagDetail, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_live_ad_tag_detail + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_live_ad_tag_detail_with_metadata` + interceptor in new development instead of the `post_get_live_ad_tag_detail` interceptor. + When both interceptors are used, this `post_get_live_ad_tag_detail_with_metadata` interceptor runs after the + `post_get_live_ad_tag_detail` interceptor. The (possibly modified) response returned by + `post_get_live_ad_tag_detail` will be passed to + `post_get_live_ad_tag_detail_with_metadata`. + """ + return response, metadata + + def pre_get_live_config(self, request: video_stitcher_service.GetLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_live_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_live_config(self, response: live_configs.LiveConfig) -> live_configs.LiveConfig: + """Post-rpc interceptor for get_live_config + + DEPRECATED. Please use the `post_get_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_live_config` interceptor runs + before the `post_get_live_config_with_metadata` interceptor. + """ + return response + + def post_get_live_config_with_metadata(self, response: live_configs.LiveConfig, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[live_configs.LiveConfig, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_live_config_with_metadata` + interceptor in new development instead of the `post_get_live_config` interceptor. + When both interceptors are used, this `post_get_live_config_with_metadata` interceptor runs after the + `post_get_live_config` interceptor. The (possibly modified) response returned by + `post_get_live_config` will be passed to + `post_get_live_config_with_metadata`. + """ + return response, metadata + + def pre_get_live_session(self, request: video_stitcher_service.GetLiveSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetLiveSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_live_session + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_live_session(self, response: sessions.LiveSession) -> sessions.LiveSession: + """Post-rpc interceptor for get_live_session + + DEPRECATED. Please use the `post_get_live_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_live_session` interceptor runs + before the `post_get_live_session_with_metadata` interceptor. + """ + return response + + def post_get_live_session_with_metadata(self, response: sessions.LiveSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.LiveSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_live_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_live_session_with_metadata` + interceptor in new development instead of the `post_get_live_session` interceptor. + When both interceptors are used, this `post_get_live_session_with_metadata` interceptor runs after the + `post_get_live_session` interceptor. The (possibly modified) response returned by + `post_get_live_session` will be passed to + `post_get_live_session_with_metadata`. + """ + return response, metadata + + def pre_get_slate(self, request: video_stitcher_service.GetSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_slate + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_slate(self, response: slates.Slate) -> slates.Slate: + """Post-rpc interceptor for get_slate + + DEPRECATED. Please use the `post_get_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_slate` interceptor runs + before the `post_get_slate_with_metadata` interceptor. + """ + return response + + def post_get_slate_with_metadata(self, response: slates.Slate, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[slates.Slate, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_slate + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_slate_with_metadata` + interceptor in new development instead of the `post_get_slate` interceptor. + When both interceptors are used, this `post_get_slate_with_metadata` interceptor runs after the + `post_get_slate` interceptor. The (possibly modified) response returned by + `post_get_slate` will be passed to + `post_get_slate_with_metadata`. + """ + return response, metadata + + def pre_get_vod_ad_tag_detail(self, request: video_stitcher_service.GetVodAdTagDetailRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodAdTagDetailRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_vod_ad_tag_detail + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_vod_ad_tag_detail(self, response: ad_tag_details.VodAdTagDetail) -> ad_tag_details.VodAdTagDetail: + """Post-rpc interceptor for get_vod_ad_tag_detail + + DEPRECATED. Please use the `post_get_vod_ad_tag_detail_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_vod_ad_tag_detail` interceptor runs + before the `post_get_vod_ad_tag_detail_with_metadata` interceptor. + """ + return response + + def post_get_vod_ad_tag_detail_with_metadata(self, response: ad_tag_details.VodAdTagDetail, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[ad_tag_details.VodAdTagDetail, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_ad_tag_detail + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_ad_tag_detail_with_metadata` + interceptor in new development instead of the `post_get_vod_ad_tag_detail` interceptor. + When both interceptors are used, this `post_get_vod_ad_tag_detail_with_metadata` interceptor runs after the + `post_get_vod_ad_tag_detail` interceptor. The (possibly modified) response returned by + `post_get_vod_ad_tag_detail` will be passed to + `post_get_vod_ad_tag_detail_with_metadata`. + """ + return response, metadata + + def pre_get_vod_config(self, request: video_stitcher_service.GetVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_vod_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_vod_config(self, response: vod_configs.VodConfig) -> vod_configs.VodConfig: + """Post-rpc interceptor for get_vod_config + + DEPRECATED. Please use the `post_get_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_vod_config` interceptor runs + before the `post_get_vod_config_with_metadata` interceptor. + """ + return response + + def post_get_vod_config_with_metadata(self, response: vod_configs.VodConfig, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[vod_configs.VodConfig, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_config_with_metadata` + interceptor in new development instead of the `post_get_vod_config` interceptor. + When both interceptors are used, this `post_get_vod_config_with_metadata` interceptor runs after the + `post_get_vod_config` interceptor. The (possibly modified) response returned by + `post_get_vod_config` will be passed to + `post_get_vod_config_with_metadata`. + """ + return response, metadata + + def pre_get_vod_session(self, request: video_stitcher_service.GetVodSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_vod_session + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_vod_session(self, response: sessions.VodSession) -> sessions.VodSession: + """Post-rpc interceptor for get_vod_session + + DEPRECATED. Please use the `post_get_vod_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_vod_session` interceptor runs + before the `post_get_vod_session_with_metadata` interceptor. + """ + return response + + def post_get_vod_session_with_metadata(self, response: sessions.VodSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.VodSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_session_with_metadata` + interceptor in new development instead of the `post_get_vod_session` interceptor. + When both interceptors are used, this `post_get_vod_session_with_metadata` interceptor runs after the + `post_get_vod_session` interceptor. The (possibly modified) response returned by + `post_get_vod_session` will be passed to + `post_get_vod_session_with_metadata`. + """ + return response, metadata + + def pre_get_vod_stitch_detail(self, request: video_stitcher_service.GetVodStitchDetailRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodStitchDetailRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_vod_stitch_detail + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_vod_stitch_detail(self, response: stitch_details.VodStitchDetail) -> stitch_details.VodStitchDetail: + """Post-rpc interceptor for get_vod_stitch_detail + + DEPRECATED. Please use the `post_get_vod_stitch_detail_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_vod_stitch_detail` interceptor runs + before the `post_get_vod_stitch_detail_with_metadata` interceptor. + """ + return response + + def post_get_vod_stitch_detail_with_metadata(self, response: stitch_details.VodStitchDetail, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[stitch_details.VodStitchDetail, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_stitch_detail + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_stitch_detail_with_metadata` + interceptor in new development instead of the `post_get_vod_stitch_detail` interceptor. + When both interceptors are used, this `post_get_vod_stitch_detail_with_metadata` interceptor runs after the + `post_get_vod_stitch_detail` interceptor. The (possibly modified) response returned by + `post_get_vod_stitch_detail` will be passed to + `post_get_vod_stitch_detail_with_metadata`. + """ + return response, metadata + + def pre_list_cdn_keys(self, request: video_stitcher_service.ListCdnKeysRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListCdnKeysRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_cdn_keys + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_cdn_keys(self, response: video_stitcher_service.ListCdnKeysResponse) -> video_stitcher_service.ListCdnKeysResponse: + """Post-rpc interceptor for list_cdn_keys + + DEPRECATED. Please use the `post_list_cdn_keys_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_cdn_keys` interceptor runs + before the `post_list_cdn_keys_with_metadata` interceptor. + """ + return response + + def post_list_cdn_keys_with_metadata(self, response: video_stitcher_service.ListCdnKeysResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListCdnKeysResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_cdn_keys + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_cdn_keys_with_metadata` + interceptor in new development instead of the `post_list_cdn_keys` interceptor. + When both interceptors are used, this `post_list_cdn_keys_with_metadata` interceptor runs after the + `post_list_cdn_keys` interceptor. The (possibly modified) response returned by + `post_list_cdn_keys` will be passed to + `post_list_cdn_keys_with_metadata`. + """ + return response, metadata + + def pre_list_live_ad_tag_details(self, request: video_stitcher_service.ListLiveAdTagDetailsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveAdTagDetailsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_live_ad_tag_details + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_live_ad_tag_details(self, response: video_stitcher_service.ListLiveAdTagDetailsResponse) -> video_stitcher_service.ListLiveAdTagDetailsResponse: + """Post-rpc interceptor for list_live_ad_tag_details + + DEPRECATED. Please use the `post_list_live_ad_tag_details_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_live_ad_tag_details` interceptor runs + before the `post_list_live_ad_tag_details_with_metadata` interceptor. + """ + return response + + def post_list_live_ad_tag_details_with_metadata(self, response: video_stitcher_service.ListLiveAdTagDetailsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveAdTagDetailsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_live_ad_tag_details + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_live_ad_tag_details_with_metadata` + interceptor in new development instead of the `post_list_live_ad_tag_details` interceptor. + When both interceptors are used, this `post_list_live_ad_tag_details_with_metadata` interceptor runs after the + `post_list_live_ad_tag_details` interceptor. The (possibly modified) response returned by + `post_list_live_ad_tag_details` will be passed to + `post_list_live_ad_tag_details_with_metadata`. + """ + return response, metadata + + def pre_list_live_configs(self, request: video_stitcher_service.ListLiveConfigsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_live_configs + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_live_configs(self, response: video_stitcher_service.ListLiveConfigsResponse) -> video_stitcher_service.ListLiveConfigsResponse: + """Post-rpc interceptor for list_live_configs + + DEPRECATED. Please use the `post_list_live_configs_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_live_configs` interceptor runs + before the `post_list_live_configs_with_metadata` interceptor. + """ + return response + + def post_list_live_configs_with_metadata(self, response: video_stitcher_service.ListLiveConfigsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveConfigsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_live_configs + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_live_configs_with_metadata` + interceptor in new development instead of the `post_list_live_configs` interceptor. + When both interceptors are used, this `post_list_live_configs_with_metadata` interceptor runs after the + `post_list_live_configs` interceptor. The (possibly modified) response returned by + `post_list_live_configs` will be passed to + `post_list_live_configs_with_metadata`. + """ + return response, metadata + + def pre_list_slates(self, request: video_stitcher_service.ListSlatesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListSlatesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_slates + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_slates(self, response: video_stitcher_service.ListSlatesResponse) -> video_stitcher_service.ListSlatesResponse: + """Post-rpc interceptor for list_slates + + DEPRECATED. Please use the `post_list_slates_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_slates` interceptor runs + before the `post_list_slates_with_metadata` interceptor. + """ + return response + + def post_list_slates_with_metadata(self, response: video_stitcher_service.ListSlatesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListSlatesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_slates + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_slates_with_metadata` + interceptor in new development instead of the `post_list_slates` interceptor. + When both interceptors are used, this `post_list_slates_with_metadata` interceptor runs after the + `post_list_slates` interceptor. The (possibly modified) response returned by + `post_list_slates` will be passed to + `post_list_slates_with_metadata`. + """ + return response, metadata + + def pre_list_vod_ad_tag_details(self, request: video_stitcher_service.ListVodAdTagDetailsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodAdTagDetailsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_vod_ad_tag_details + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_vod_ad_tag_details(self, response: video_stitcher_service.ListVodAdTagDetailsResponse) -> video_stitcher_service.ListVodAdTagDetailsResponse: + """Post-rpc interceptor for list_vod_ad_tag_details + + DEPRECATED. Please use the `post_list_vod_ad_tag_details_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_vod_ad_tag_details` interceptor runs + before the `post_list_vod_ad_tag_details_with_metadata` interceptor. + """ + return response + + def post_list_vod_ad_tag_details_with_metadata(self, response: video_stitcher_service.ListVodAdTagDetailsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodAdTagDetailsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_vod_ad_tag_details + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_vod_ad_tag_details_with_metadata` + interceptor in new development instead of the `post_list_vod_ad_tag_details` interceptor. + When both interceptors are used, this `post_list_vod_ad_tag_details_with_metadata` interceptor runs after the + `post_list_vod_ad_tag_details` interceptor. The (possibly modified) response returned by + `post_list_vod_ad_tag_details` will be passed to + `post_list_vod_ad_tag_details_with_metadata`. + """ + return response, metadata + + def pre_list_vod_configs(self, request: video_stitcher_service.ListVodConfigsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_vod_configs + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_vod_configs(self, response: video_stitcher_service.ListVodConfigsResponse) -> video_stitcher_service.ListVodConfigsResponse: + """Post-rpc interceptor for list_vod_configs + + DEPRECATED. Please use the `post_list_vod_configs_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_vod_configs` interceptor runs + before the `post_list_vod_configs_with_metadata` interceptor. + """ + return response + + def post_list_vod_configs_with_metadata(self, response: video_stitcher_service.ListVodConfigsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodConfigsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_vod_configs + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_vod_configs_with_metadata` + interceptor in new development instead of the `post_list_vod_configs` interceptor. + When both interceptors are used, this `post_list_vod_configs_with_metadata` interceptor runs after the + `post_list_vod_configs` interceptor. The (possibly modified) response returned by + `post_list_vod_configs` will be passed to + `post_list_vod_configs_with_metadata`. + """ + return response, metadata + + def pre_list_vod_stitch_details(self, request: video_stitcher_service.ListVodStitchDetailsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodStitchDetailsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_vod_stitch_details + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_vod_stitch_details(self, response: video_stitcher_service.ListVodStitchDetailsResponse) -> video_stitcher_service.ListVodStitchDetailsResponse: + """Post-rpc interceptor for list_vod_stitch_details + + DEPRECATED. Please use the `post_list_vod_stitch_details_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_vod_stitch_details` interceptor runs + before the `post_list_vod_stitch_details_with_metadata` interceptor. + """ + return response + + def post_list_vod_stitch_details_with_metadata(self, response: video_stitcher_service.ListVodStitchDetailsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodStitchDetailsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for list_vod_stitch_details + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_vod_stitch_details_with_metadata` + interceptor in new development instead of the `post_list_vod_stitch_details` interceptor. + When both interceptors are used, this `post_list_vod_stitch_details_with_metadata` interceptor runs after the + `post_list_vod_stitch_details` interceptor. The (possibly modified) response returned by + `post_list_vod_stitch_details` will be passed to + `post_list_vod_stitch_details_with_metadata`. + """ + return response, metadata + + def pre_update_cdn_key(self, request: video_stitcher_service.UpdateCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_cdn_key + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_update_cdn_key(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_cdn_key + + DEPRECATED. Please use the `post_update_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_update_cdn_key` interceptor runs + before the `post_update_cdn_key_with_metadata` interceptor. + """ + return response + + def post_update_cdn_key_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_cdn_key_with_metadata` + interceptor in new development instead of the `post_update_cdn_key` interceptor. + When both interceptors are used, this `post_update_cdn_key_with_metadata` interceptor runs after the + `post_update_cdn_key` interceptor. The (possibly modified) response returned by + `post_update_cdn_key` will be passed to + `post_update_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_update_live_config(self, request: video_stitcher_service.UpdateLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_live_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_update_live_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_live_config + + DEPRECATED. Please use the `post_update_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_update_live_config` interceptor runs + before the `post_update_live_config_with_metadata` interceptor. + """ + return response + + def post_update_live_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_live_config_with_metadata` + interceptor in new development instead of the `post_update_live_config` interceptor. + When both interceptors are used, this `post_update_live_config_with_metadata` interceptor runs after the + `post_update_live_config` interceptor. The (possibly modified) response returned by + `post_update_live_config` will be passed to + `post_update_live_config_with_metadata`. + """ + return response, metadata + + def pre_update_slate(self, request: video_stitcher_service.UpdateSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_slate + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_update_slate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_slate + + DEPRECATED. Please use the `post_update_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_update_slate` interceptor runs + before the `post_update_slate_with_metadata` interceptor. + """ + return response + + def post_update_slate_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_slate + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_slate_with_metadata` + interceptor in new development instead of the `post_update_slate` interceptor. + When both interceptors are used, this `post_update_slate_with_metadata` interceptor runs after the + `post_update_slate` interceptor. The (possibly modified) response returned by + `post_update_slate` will be passed to + `post_update_slate_with_metadata`. + """ + return response, metadata + + def pre_update_vod_config(self, request: video_stitcher_service.UpdateVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for update_vod_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_update_vod_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: + """Post-rpc interceptor for update_vod_config + + DEPRECATED. Please use the `post_update_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_update_vod_config` interceptor runs + before the `post_update_vod_config_with_metadata` interceptor. + """ + return response + + def post_update_vod_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_vod_config_with_metadata` + interceptor in new development instead of the `post_update_vod_config` interceptor. + When both interceptors are used, this `post_update_vod_config_with_metadata` interceptor runs after the + `post_update_vod_config` interceptor. The (possibly modified) response returned by + `post_update_vod_config` will be passed to + `post_update_vod_config_with_metadata`. + """ + return response, metadata + + def pre_cancel_operation( + self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService 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 VideoStitcherService server but before + it is returned to user code. + """ + return response + + def pre_delete_operation( + self, request: operations_pb2.DeleteOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for delete_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_delete_operation( + self, response: None + ) -> None: + """Post-rpc interceptor for delete_operation + + Override in a subclass to manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. + """ + return response + + def pre_get_operation( + self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for get_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService 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 VideoStitcherService server but before + it is returned to user code. + """ + return response + + def pre_list_operations( + self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: + """Pre-rpc interceptor for list_operations + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService 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 VideoStitcherService server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class VideoStitcherServiceRestStub: + _session: AuthorizedSession + _host: str + _interceptor: VideoStitcherServiceRestInterceptor + + +class VideoStitcherServiceRestTransport(_BaseVideoStitcherServiceRestTransport): + """REST backend synchronous transport for VideoStitcherService. + + Video-On-Demand content stitching API allows you to insert + ads into (VoD) video on demand files. You will be able to render + custom scrubber bars with highlighted ads, enforce ad policies, + allow seamless playback and tracking on native players and + monetize content with any standard VMAP compliant ad server. + + 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 = 'videostitcher.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[VideoStitcherServiceRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to (default: 'videostitcher.googleapis.com'). + 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 + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + url_scheme=url_scheme, + 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 VideoStitcherServiceRestInterceptor() + self._prep_wrapped_messages(client_info) + + @property + def operations_client(self) -> operations_v1.AbstractOperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Only create a new client if we do not already have one. + if self._operations_client is None: + http_options: Dict[str, List[Dict[str, str]]] = { + 'google.longrunning.Operations.CancelOperation': [ + { + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body': '*', + }, + ], + 'google.longrunning.Operations.DeleteOperation': [ + { + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ], + 'google.longrunning.Operations.GetOperation': [ + { + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ], + 'google.longrunning.Operations.ListOperations': [ + { + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}/operations', + }, + ], + } + + rest_transport = operations_v1.OperationsRestTransport( + host=self._host, + # use the credentials which are saved + credentials=self._credentials, + scopes=self._scopes, + http_options=http_options, + path_prefix="v1") + + self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) + + # Return the client from cache. + return self._operations_client + + class _CreateCdnKey(_BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.CreateCdnKeyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create cdn key method over HTTP. + + Args: + request (~.video_stitcher_service.CreateCdnKeyRequest): + The request object. Request message for + VideoStitcherService.createCdnKey. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_http_options() + + request, metadata = self._interceptor.pre_create_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateCdnKey", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_cdn_key_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_cdn_key", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.CreateLiveConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create live config method over HTTP. + + Args: + request (~.video_stitcher_service.CreateLiveConfigRequest): + The request object. Request message for + VideoStitcherService.createLiveConfig + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_http_options() + + request, metadata = self._interceptor.pre_create_live_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateLiveConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_live_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateLiveSession(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateLiveSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.CreateLiveSessionRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> sessions.LiveSession: + r"""Call the create live session method over HTTP. + + Args: + request (~.video_stitcher_service.CreateLiveSessionRequest): + The request object. Request message for + VideoStitcherService.createLiveSession. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.sessions.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_http_options() + + request, metadata = self._interceptor.pre_create_live_session(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateLiveSession", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateLiveSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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 = sessions.LiveSession() + pb_resp = sessions.LiveSession.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_live_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_live_session_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = sessions.LiveSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_session", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateSlate(_BaseVideoStitcherServiceRestTransport._BaseCreateSlate, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.CreateSlateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create slate method over HTTP. + + Args: + request (~.video_stitcher_service.CreateSlateRequest): + The request object. Request message for + VideoStitcherService.createSlate. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_http_options() + + request, metadata = self._interceptor.pre_create_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateSlate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_slate_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_slate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateVodConfig(_BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.CreateVodConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the create vod config method over HTTP. + + Args: + request (~.video_stitcher_service.CreateVodConfigRequest): + The request object. Request message for + VideoStitcherService.createVodConfig + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_http_options() + + request, metadata = self._interceptor.pre_create_vod_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateVodConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_vod_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateVodSession(_BaseVideoStitcherServiceRestTransport._BaseCreateVodSession, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateVodSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.CreateVodSessionRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> sessions.VodSession: + r"""Call the create vod session method over HTTP. + + Args: + request (~.video_stitcher_service.CreateVodSessionRequest): + The request object. Request message for + VideoStitcherService.createVodSession + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.sessions.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_http_options() + + request, metadata = self._interceptor.pre_create_vod_session(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateVodSession", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateVodSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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 = sessions.VodSession() + pb_resp = sessions.VodSession.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_vod_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_vod_session_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = sessions.VodSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_session", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteCdnKey(_BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.DeleteCdnKeyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete cdn key method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteCdnKeyRequest): + The request object. Request message for + VideoStitcherService.deleteCdnKey. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_http_options() + + request, metadata = self._interceptor.pre_delete_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteCdnKey", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_cdn_key_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_cdn_key", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.DeleteLiveConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete live config method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteLiveConfigRequest): + The request object. Request message for + VideoStitcherService.deleteLiveConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_http_options() + + request, metadata = self._interceptor.pre_delete_live_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteLiveConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_live_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_live_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteSlate(_BaseVideoStitcherServiceRestTransport._BaseDeleteSlate, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.DeleteSlateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete slate method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteSlateRequest): + The request object. Request message for + VideoStitcherService.deleteSlate. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_http_options() + + request, metadata = self._interceptor.pre_delete_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteSlate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_slate_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_slate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteVodConfig(_BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.DeleteVodConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the delete vod config method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteVodConfigRequest): + The request object. Request message for + VideoStitcherService.deleteVodConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_http_options() + + request, metadata = self._interceptor.pre_delete_vod_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteVodConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_vod_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_vod_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetCdnKey(_BaseVideoStitcherServiceRestTransport._BaseGetCdnKey, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetCdnKeyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> cdn_keys.CdnKey: + r"""Call the get cdn key method over HTTP. + + Args: + request (~.video_stitcher_service.GetCdnKeyRequest): + The request object. Request message for + VideoStitcherService.getCdnKey. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.cdn_keys.CdnKey: + Configuration for a CDN key. Used by + the Video Stitcher to sign URIs for + fetching video manifests and signing + media segments for playback. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_http_options() + + request, metadata = self._interceptor.pre_get_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetCdnKey", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = cdn_keys.CdnKey() + pb_resp = cdn_keys.CdnKey.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_cdn_key_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = cdn_keys.CdnKey.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_cdn_key", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetLiveAdTagDetail(_BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetLiveAdTagDetail") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetLiveAdTagDetailRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> ad_tag_details.LiveAdTagDetail: + r"""Call the get live ad tag detail method over HTTP. + + Args: + request (~.video_stitcher_service.GetLiveAdTagDetailRequest): + The request object. Request message for + VideoStitcherService.getLiveAdTagDetail + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.ad_tag_details.LiveAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for live sessions that do not + implement Google Ad Manager ad + insertion. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_http_options() + + request, metadata = self._interceptor.pre_get_live_ad_tag_detail(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveAdTagDetail", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveAdTagDetail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetLiveAdTagDetail._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = ad_tag_details.LiveAdTagDetail() + pb_resp = ad_tag_details.LiveAdTagDetail.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_live_ad_tag_detail(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_live_ad_tag_detail_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = ad_tag_details.LiveAdTagDetail.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_ad_tag_detail", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveAdTagDetail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetLiveConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> live_configs.LiveConfig: + r"""Call the get live config method over HTTP. + + Args: + request (~.video_stitcher_service.GetLiveConfigRequest): + The request object. Request message for + VideoStitcherService.getLiveConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.live_configs.LiveConfig: + Metadata for used to register live + configs. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_http_options() + + request, metadata = self._interceptor.pre_get_live_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = live_configs.LiveConfig() + pb_resp = live_configs.LiveConfig.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_live_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = live_configs.LiveConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetLiveSession(_BaseVideoStitcherServiceRestTransport._BaseGetLiveSession, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetLiveSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetLiveSessionRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> sessions.LiveSession: + r"""Call the get live session method over HTTP. + + Args: + request (~.video_stitcher_service.GetLiveSessionRequest): + The request object. Request message for + VideoStitcherService.getSession. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.sessions.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_http_options() + + request, metadata = self._interceptor.pre_get_live_session(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveSession", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetLiveSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = sessions.LiveSession() + pb_resp = sessions.LiveSession.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_live_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_live_session_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = sessions.LiveSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_session", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetSlate(_BaseVideoStitcherServiceRestTransport._BaseGetSlate, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetSlateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> slates.Slate: + r"""Call the get slate method over HTTP. + + Args: + request (~.video_stitcher_service.GetSlateRequest): + The request object. Request message for + VideoStitcherService.getSlate. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.slates.Slate: + Slate object + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_http_options() + + request, metadata = self._interceptor.pre_get_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetSlate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = slates.Slate() + pb_resp = slates.Slate.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_slate_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = slates.Slate.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_slate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetVodAdTagDetail(_BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetVodAdTagDetail") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetVodAdTagDetailRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> ad_tag_details.VodAdTagDetail: + r"""Call the get vod ad tag detail method over HTTP. + + Args: + request (~.video_stitcher_service.GetVodAdTagDetailRequest): + The request object. Request message for + VideoStitcherService.getVodAdTagDetail + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.ad_tag_details.VodAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for VOD sessions that do not + implement Google Ad Manager ad + insertion. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_http_options() + + request, metadata = self._interceptor.pre_get_vod_ad_tag_detail(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodAdTagDetail", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodAdTagDetail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetVodAdTagDetail._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = ad_tag_details.VodAdTagDetail() + pb_resp = ad_tag_details.VodAdTagDetail.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_vod_ad_tag_detail(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_ad_tag_detail_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = ad_tag_details.VodAdTagDetail.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_ad_tag_detail", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodAdTagDetail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetVodConfig(_BaseVideoStitcherServiceRestTransport._BaseGetVodConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetVodConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> vod_configs.VodConfig: + r"""Call the get vod config method over HTTP. + + Args: + request (~.video_stitcher_service.GetVodConfigRequest): + The request object. Request message for + VideoStitcherService.getVodConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.vod_configs.VodConfig: + Metadata used to register VOD + configs. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_http_options() + + request, metadata = self._interceptor.pre_get_vod_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = vod_configs.VodConfig() + pb_resp = vod_configs.VodConfig.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = vod_configs.VodConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetVodSession(_BaseVideoStitcherServiceRestTransport._BaseGetVodSession, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetVodSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetVodSessionRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> sessions.VodSession: + r"""Call the get vod session method over HTTP. + + Args: + request (~.video_stitcher_service.GetVodSessionRequest): + The request object. Request message for + VideoStitcherService.getVodSession + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.sessions.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_http_options() + + request, metadata = self._interceptor.pre_get_vod_session(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodSession", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetVodSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = sessions.VodSession() + pb_resp = sessions.VodSession.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_vod_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_session_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = sessions.VodSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_session", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetVodStitchDetail(_BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetVodStitchDetail") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.GetVodStitchDetailRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> stitch_details.VodStitchDetail: + r"""Call the get vod stitch detail method over HTTP. + + Args: + request (~.video_stitcher_service.GetVodStitchDetailRequest): + The request object. Request message for + VideoStitcherService.getVodStitchDetail. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.stitch_details.VodStitchDetail: + Information related to the + interstitial of a VOD session. This + resource is only available for VOD + sessions that do not implement Google Ad + Manager ad insertion. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_http_options() + + request, metadata = self._interceptor.pre_get_vod_stitch_detail(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodStitchDetail", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodStitchDetail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetVodStitchDetail._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = stitch_details.VodStitchDetail() + pb_resp = stitch_details.VodStitchDetail.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_get_vod_stitch_detail(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_stitch_detail_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = stitch_details.VodStitchDetail.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_stitch_detail", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodStitchDetail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListCdnKeys(_BaseVideoStitcherServiceRestTransport._BaseListCdnKeys, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListCdnKeys") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.ListCdnKeysRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> video_stitcher_service.ListCdnKeysResponse: + r"""Call the list cdn keys method over HTTP. + + Args: + request (~.video_stitcher_service.ListCdnKeysRequest): + The request object. Request message for + VideoStitcherService.listCdnKeys. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.video_stitcher_service.ListCdnKeysResponse: + Response message for + VideoStitcher.ListCdnKeys. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_http_options() + + request, metadata = self._interceptor.pre_list_cdn_keys(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListCdnKeys", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListCdnKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListCdnKeys._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = video_stitcher_service.ListCdnKeysResponse() + pb_resp = video_stitcher_service.ListCdnKeysResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_cdn_keys(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_cdn_keys_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = video_stitcher_service.ListCdnKeysResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_cdn_keys", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListCdnKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListLiveAdTagDetails(_BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListLiveAdTagDetails") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.ListLiveAdTagDetailsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> video_stitcher_service.ListLiveAdTagDetailsResponse: + r"""Call the list live ad tag details method over HTTP. + + Args: + request (~.video_stitcher_service.ListLiveAdTagDetailsRequest): + The request object. Request message for + VideoStitcherService.listLiveAdTagDetails. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.video_stitcher_service.ListLiveAdTagDetailsResponse: + Response message for + VideoStitcherService.listLiveAdTagDetails. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_http_options() + + request, metadata = self._interceptor.pre_list_live_ad_tag_details(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListLiveAdTagDetails", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveAdTagDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListLiveAdTagDetails._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = video_stitcher_service.ListLiveAdTagDetailsResponse() + pb_resp = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_live_ad_tag_details(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_live_ad_tag_details_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = video_stitcher_service.ListLiveAdTagDetailsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_ad_tag_details", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveAdTagDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListLiveConfigs(_BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListLiveConfigs") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.ListLiveConfigsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> video_stitcher_service.ListLiveConfigsResponse: + r"""Call the list live configs method over HTTP. + + Args: + request (~.video_stitcher_service.ListLiveConfigsRequest): + The request object. Request message for + VideoStitcherService.listLiveConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.video_stitcher_service.ListLiveConfigsResponse: + Response message for + VideoStitcher.ListLiveConfig. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_http_options() + + request, metadata = self._interceptor.pre_list_live_configs(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListLiveConfigs", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListLiveConfigs._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = video_stitcher_service.ListLiveConfigsResponse() + pb_resp = video_stitcher_service.ListLiveConfigsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_live_configs(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_live_configs_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = video_stitcher_service.ListLiveConfigsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_configs", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListSlates(_BaseVideoStitcherServiceRestTransport._BaseListSlates, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListSlates") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.ListSlatesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> video_stitcher_service.ListSlatesResponse: + r"""Call the list slates method over HTTP. + + Args: + request (~.video_stitcher_service.ListSlatesRequest): + The request object. Request message for + VideoStitcherService.listSlates. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.video_stitcher_service.ListSlatesResponse: + Response message for + VideoStitcherService.listSlates. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_http_options() + + request, metadata = self._interceptor.pre_list_slates(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListSlates", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListSlates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListSlates._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = video_stitcher_service.ListSlatesResponse() + pb_resp = video_stitcher_service.ListSlatesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_slates(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_slates_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = video_stitcher_service.ListSlatesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_slates", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListSlates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListVodAdTagDetails(_BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListVodAdTagDetails") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.ListVodAdTagDetailsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> video_stitcher_service.ListVodAdTagDetailsResponse: + r"""Call the list vod ad tag details method over HTTP. + + Args: + request (~.video_stitcher_service.ListVodAdTagDetailsRequest): + The request object. Request message for + VideoStitcherService.listVodAdTagDetails. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.video_stitcher_service.ListVodAdTagDetailsResponse: + Response message for + VideoStitcherService.listVodAdTagDetails. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_http_options() + + request, metadata = self._interceptor.pre_list_vod_ad_tag_details(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodAdTagDetails", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodAdTagDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListVodAdTagDetails._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = video_stitcher_service.ListVodAdTagDetailsResponse() + pb_resp = video_stitcher_service.ListVodAdTagDetailsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_vod_ad_tag_details(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_vod_ad_tag_details_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = video_stitcher_service.ListVodAdTagDetailsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_ad_tag_details", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodAdTagDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListVodConfigs(_BaseVideoStitcherServiceRestTransport._BaseListVodConfigs, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListVodConfigs") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.ListVodConfigsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> video_stitcher_service.ListVodConfigsResponse: + r"""Call the list vod configs method over HTTP. + + Args: + request (~.video_stitcher_service.ListVodConfigsRequest): + The request object. Request message for + VideoStitcherService.listVodConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.video_stitcher_service.ListVodConfigsResponse: + Response message for + VideoStitcher.ListVodConfig. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_http_options() + + request, metadata = self._interceptor.pre_list_vod_configs(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodConfigs", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListVodConfigs._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = video_stitcher_service.ListVodConfigsResponse() + pb_resp = video_stitcher_service.ListVodConfigsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_vod_configs(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_vod_configs_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = video_stitcher_service.ListVodConfigsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_configs", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _ListVodStitchDetails(_BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListVodStitchDetails") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: video_stitcher_service.ListVodStitchDetailsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> video_stitcher_service.ListVodStitchDetailsResponse: + r"""Call the list vod stitch details method over HTTP. + + Args: + request (~.video_stitcher_service.ListVodStitchDetailsRequest): + The request object. Request message for + VideoStitcherService.listVodStitchDetails. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.video_stitcher_service.ListVodStitchDetailsResponse: + Response message for + VideoStitcherService.listVodStitchDetails. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_http_options() + + request, metadata = self._interceptor.pre_list_vod_stitch_details(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodStitchDetails", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodStitchDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListVodStitchDetails._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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 = video_stitcher_service.ListVodStitchDetailsResponse() + pb_resp = video_stitcher_service.ListVodStitchDetailsResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_list_vod_stitch_details(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_vod_stitch_details_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = video_stitcher_service.ListVodStitchDetailsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_stitch_details", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodStitchDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateCdnKey(_BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.UpdateCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.UpdateCdnKeyRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update cdn key method over HTTP. + + Args: + request (~.video_stitcher_service.UpdateCdnKeyRequest): + The request object. Request message for + VideoStitcherService.updateCdnKey. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_http_options() + + request, metadata = self._interceptor.pre_update_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateCdnKey", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._UpdateCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_cdn_key_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_cdn_key", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.UpdateLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.UpdateLiveConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update live config method over HTTP. + + Args: + request (~.video_stitcher_service.UpdateLiveConfigRequest): + The request object. Request message for + VideoStitcherService.updateLiveConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_http_options() + + request, metadata = self._interceptor.pre_update_live_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateLiveConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._UpdateLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_live_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_live_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateSlate(_BaseVideoStitcherServiceRestTransport._BaseUpdateSlate, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.UpdateSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.UpdateSlateRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update slate method over HTTP. + + Args: + request (~.video_stitcher_service.UpdateSlateRequest): + The request object. Request message for + VideoStitcherService.updateSlate. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_http_options() + + request, metadata = self._interceptor.pre_update_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateSlate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._UpdateSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_slate_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_slate", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _UpdateVodConfig(_BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.UpdateVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: video_stitcher_service.UpdateVodConfigRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> operations_pb2.Operation: + r"""Call the update vod config method over HTTP. + + Args: + request (~.video_stitcher_service.UpdateVodConfigRequest): + The request object. Request message for + VideoStitcherService.updateVodConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_http_options() + + request, metadata = self._interceptor.pre_update_vod_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateVodConfig", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._UpdateVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_vod_config_with_metadata(resp, response_metadata) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_vod_config", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + @property + def create_cdn_key(self) -> Callable[ + [video_stitcher_service.CreateCdnKeyRequest], + 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._CreateCdnKey(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_live_config(self) -> Callable[ + [video_stitcher_service.CreateLiveConfigRequest], + 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._CreateLiveConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_live_session(self) -> Callable[ + [video_stitcher_service.CreateLiveSessionRequest], + sessions.LiveSession]: + # 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._CreateLiveSession(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_slate(self) -> Callable[ + [video_stitcher_service.CreateSlateRequest], + 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._CreateSlate(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_vod_config(self) -> Callable[ + [video_stitcher_service.CreateVodConfigRequest], + 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._CreateVodConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_vod_session(self) -> Callable[ + [video_stitcher_service.CreateVodSessionRequest], + sessions.VodSession]: + # 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._CreateVodSession(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_cdn_key(self) -> Callable[ + [video_stitcher_service.DeleteCdnKeyRequest], + 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._DeleteCdnKey(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_live_config(self) -> Callable[ + [video_stitcher_service.DeleteLiveConfigRequest], + 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._DeleteLiveConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_slate(self) -> Callable[ + [video_stitcher_service.DeleteSlateRequest], + 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._DeleteSlate(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_vod_config(self) -> Callable[ + [video_stitcher_service.DeleteVodConfigRequest], + 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._DeleteVodConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_cdn_key(self) -> Callable[ + [video_stitcher_service.GetCdnKeyRequest], + cdn_keys.CdnKey]: + # 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._GetCdnKey(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_live_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetLiveAdTagDetailRequest], + ad_tag_details.LiveAdTagDetail]: + # 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._GetLiveAdTagDetail(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_live_config(self) -> Callable[ + [video_stitcher_service.GetLiveConfigRequest], + live_configs.LiveConfig]: + # 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._GetLiveConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_live_session(self) -> Callable[ + [video_stitcher_service.GetLiveSessionRequest], + sessions.LiveSession]: + # 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._GetLiveSession(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_slate(self) -> Callable[ + [video_stitcher_service.GetSlateRequest], + slates.Slate]: + # 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._GetSlate(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_vod_ad_tag_detail(self) -> Callable[ + [video_stitcher_service.GetVodAdTagDetailRequest], + ad_tag_details.VodAdTagDetail]: + # 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._GetVodAdTagDetail(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_vod_config(self) -> Callable[ + [video_stitcher_service.GetVodConfigRequest], + vod_configs.VodConfig]: + # 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._GetVodConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_vod_session(self) -> Callable[ + [video_stitcher_service.GetVodSessionRequest], + sessions.VodSession]: + # 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._GetVodSession(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_vod_stitch_detail(self) -> Callable[ + [video_stitcher_service.GetVodStitchDetailRequest], + stitch_details.VodStitchDetail]: + # 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._GetVodStitchDetail(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_cdn_keys(self) -> Callable[ + [video_stitcher_service.ListCdnKeysRequest], + video_stitcher_service.ListCdnKeysResponse]: + # 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._ListCdnKeys(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_live_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListLiveAdTagDetailsRequest], + video_stitcher_service.ListLiveAdTagDetailsResponse]: + # 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._ListLiveAdTagDetails(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_live_configs(self) -> Callable[ + [video_stitcher_service.ListLiveConfigsRequest], + video_stitcher_service.ListLiveConfigsResponse]: + # 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._ListLiveConfigs(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_slates(self) -> Callable[ + [video_stitcher_service.ListSlatesRequest], + video_stitcher_service.ListSlatesResponse]: + # 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._ListSlates(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_vod_ad_tag_details(self) -> Callable[ + [video_stitcher_service.ListVodAdTagDetailsRequest], + video_stitcher_service.ListVodAdTagDetailsResponse]: + # 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._ListVodAdTagDetails(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_vod_configs(self) -> Callable[ + [video_stitcher_service.ListVodConfigsRequest], + video_stitcher_service.ListVodConfigsResponse]: + # 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._ListVodConfigs(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_vod_stitch_details(self) -> Callable[ + [video_stitcher_service.ListVodStitchDetailsRequest], + video_stitcher_service.ListVodStitchDetailsResponse]: + # 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._ListVodStitchDetails(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_cdn_key(self) -> Callable[ + [video_stitcher_service.UpdateCdnKeyRequest], + 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._UpdateCdnKey(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_live_config(self) -> Callable[ + [video_stitcher_service.UpdateLiveConfigRequest], + 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._UpdateLiveConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_slate(self) -> Callable[ + [video_stitcher_service.UpdateSlateRequest], + 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._UpdateSlate(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_vod_config(self) -> Callable[ + [video_stitcher_service.UpdateVodConfigRequest], + 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._UpdateVodConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def cancel_operation(self): + return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore + + class _CancelOperation(_BaseVideoStitcherServiceRestTransport._BaseCancelOperation, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CancelOperation") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__(self, + request: operations_pb2.CancelOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_http_options() + + request, metadata = self._interceptor.pre_cancel_operation(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_transcoded_request(http_options, request) + + body = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_request_body_json(transcoded_request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CancelOperation", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CancelOperation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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 self._interceptor.post_cancel_operation(None) + + @property + def delete_operation(self): + return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore + + class _DeleteOperation(_BaseVideoStitcherServiceRestTransport._BaseDeleteOperation, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteOperation") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: operations_pb2.DeleteOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> None: + + r"""Call the delete operation method over HTTP. + + Args: + request (operations_pb2.DeleteOperationRequest): + The request object for DeleteOperation method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_http_options() + + request, metadata = self._interceptor.pre_delete_operation(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteOperation", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteOperation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # 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_delete_operation(None) + + @property + def get_operation(self): + return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore + + class _GetOperation(_BaseVideoStitcherServiceRestTransport._BaseGetOperation, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetOperation") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: operations_pb2.GetOperationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + operations_pb2.Operation: Response from GetOperation method. + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_http_options() + + request, metadata = self._interceptor.pre_get_operation(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetOperation", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetOperation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + content = response.content.decode("utf-8") + resp = operations_pb2.Operation() + resp = json_format.Parse(content, resp) + resp = self._interceptor.post_get_operation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.GetOperation", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + + @property + def list_operations(self): + return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore + + class _ListOperations(_BaseVideoStitcherServiceRestTransport._BaseListOperations, VideoStitcherServiceRestStub): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListOperations") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None): + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__(self, + request: operations_pb2.ListOperationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + operations_pb2.ListOperationsResponse: Response from ListOperations method. + """ + + http_options = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_http_options() + + request, metadata = self._interceptor.pre_list_operations(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_transcoded_request(http_options, request) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_query_params_json(transcoded_request) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) + method = transcoded_request['method'] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListOperations", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListOperations._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + content = response.content.decode("utf-8") + resp = operations_pb2.ListOperationsResponse() + resp = json_format.Parse(content, resp) + resp = self._interceptor.post_list_operations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.ListOperations", + extra = { + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + + @property + def kind(self) -> str: + return "rest" + + def close(self): + self._session.close() + + +__all__=( + 'VideoStitcherServiceRestTransport', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py new file mode 100644 index 000000000000..8b3bd977873e --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py @@ -0,0 +1,1414 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 json # type: ignore +from google.api_core import path_template +from google.api_core import gapic_v1 + +from google.protobuf import json_format +from .base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO + +import re +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union + + +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore + + +class _BaseVideoStitcherServiceRestTransport(VideoStitcherServiceTransport): + """Base REST backend transport for VideoStitcherService. + + Note: This class is not meant to be used directly. Use its sync and + async sub-classes instead. + + 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 = 'videostitcher.googleapis.com', + credentials: Optional[Any] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = 'https', + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + Args: + host (Optional[str]): + The hostname to connect to (default: 'videostitcher.googleapis.com'). + credentials (Optional[Any]): 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. + 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 + 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 + ) + + class _BaseCreateCdnKey: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "cdnKeyId" : "", } + + @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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/cdnKeys', + 'body': 'cdn_key', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.CreateCdnKeyRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateLiveConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "liveConfigId" : "", } + + @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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/liveConfigs', + 'body': 'live_config', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.CreateLiveConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateLiveSession: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/liveSessions', + 'body': 'live_session', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.CreateLiveSessionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateSlate: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "slateId" : "", } + + @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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/slates', + 'body': 'slate', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.CreateSlateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateVodConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "vodConfigId" : "", } + + @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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/vodConfigs', + 'body': 'vod_config', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.CreateVodConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCreateVodSession: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/vodSessions', + 'body': 'vod_session', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.CreateVodSessionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteCdnKey: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/cdnKeys/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.DeleteCdnKeyRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteLiveConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/liveConfigs/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.DeleteLiveConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteSlate: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/slates/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.DeleteSlateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseDeleteVodConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/vodConfigs/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.DeleteVodConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetCdnKey: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/cdnKeys/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetCdnKeyRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetLiveAdTagDetail: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/liveSessions/*/liveAdTagDetails/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetLiveAdTagDetailRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetLiveConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/liveConfigs/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetLiveConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetLiveSession: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/liveSessions/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetLiveSessionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetSlate: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/slates/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetSlateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetVodAdTagDetail: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/vodSessions/*/vodAdTagDetails/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetVodAdTagDetailRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetVodConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/vodConfigs/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetVodConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetVodSession: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/vodSessions/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetVodSessionRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseGetVodStitchDetail: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/vodSessions/*/vodStitchDetails/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.GetVodStitchDetailRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListCdnKeys: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/cdnKeys', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.ListCdnKeysRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListLiveAdTagDetails: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*/liveSessions/*}/liveAdTagDetails', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.ListLiveAdTagDetailsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListLiveConfigs: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/liveConfigs', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.ListLiveConfigsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListSlates: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/slates', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.ListSlatesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListSlates._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListVodAdTagDetails: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*/vodSessions/*}/vodAdTagDetails', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.ListVodAdTagDetailsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListVodConfigs: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/vodConfigs', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.ListVodConfigsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseListVodStitchDetails: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*/vodSessions/*}/vodStitchDetails', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.ListVodStitchDetailsRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateCdnKey: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{cdn_key.name=projects/*/locations/*/cdnKeys/*}', + 'body': 'cdn_key', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.UpdateCdnKeyRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateLiveConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{live_config.name=projects/*/locations/*/liveConfigs/*}', + 'body': 'live_config', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.UpdateLiveConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateSlate: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{slate.name=projects/*/locations/*/slates/*}', + 'body': 'slate', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.UpdateSlateRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseUpdateVodConfig: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + __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} + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{vod_config.name=projects/*/locations/*/vodConfigs/*}', + 'body': 'vod_config', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + pb_request = video_stitcher_service.UpdateVodConfigRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + use_integers_for_enums=True + ) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + use_integers_for_enums=True, + )) + query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + return query_params + + class _BaseCancelOperation: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', + 'body': '*', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + return transcoded_request + + @staticmethod + def _get_request_body_json(transcoded_request): + body = json.dumps(transcoded_request['body']) + return body + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + return query_params + + class _BaseDeleteOperation: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + return query_params + + class _BaseGetOperation: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/operations/*}', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + return query_params + + class _BaseListOperations: + def __hash__(self): # pragma: NO COVER + return NotImplementedError("__hash__ must be implemented.") + + @staticmethod + def _get_http_options(): + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}/operations', + }, + ] + return http_options + + @staticmethod + def _get_transcoded_request(http_options, request): + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + return transcoded_request + + @staticmethod + def _get_query_params_json(transcoded_request): + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + return query_params + + +__all__=( + '_BaseVideoStitcherServiceRestTransport', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py new file mode 100644 index 000000000000..5e827f8ab244 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py @@ -0,0 +1,184 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 .ad_tag_details import ( + AdRequest, + LiveAdTagDetail, + RequestMetadata, + ResponseMetadata, + VodAdTagDetail, +) +from .cdn_keys import ( + AkamaiCdnKey, + CdnKey, + GoogleCdnKey, + MediaCdnKey, +) +from .companions import ( + Companion, + CompanionAds, + HtmlAdResource, + IframeAdResource, + StaticAdResource, +) +from .events import ( + Event, + ProgressEvent, +) +from .fetch_options import ( + FetchOptions, +) +from .live_configs import ( + GamLiveConfig, + LiveConfig, + PrefetchConfig, + AdTracking, +) +from .sessions import ( + Interstitials, + LiveSession, + ManifestOptions, + RenditionFilter, + VodSession, + VodSessionAd, + VodSessionAdBreak, + VodSessionContent, +) +from .slates import ( + Slate, +) +from .stitch_details import ( + AdStitchDetail, + VodStitchDetail, +) +from .video_stitcher_service import ( + CreateCdnKeyRequest, + CreateLiveConfigRequest, + CreateLiveSessionRequest, + CreateSlateRequest, + CreateVodConfigRequest, + CreateVodSessionRequest, + DeleteCdnKeyRequest, + DeleteLiveConfigRequest, + DeleteSlateRequest, + DeleteVodConfigRequest, + GetCdnKeyRequest, + GetLiveAdTagDetailRequest, + GetLiveConfigRequest, + GetLiveSessionRequest, + GetSlateRequest, + GetVodAdTagDetailRequest, + GetVodConfigRequest, + GetVodSessionRequest, + GetVodStitchDetailRequest, + ListCdnKeysRequest, + ListCdnKeysResponse, + ListLiveAdTagDetailsRequest, + ListLiveAdTagDetailsResponse, + ListLiveConfigsRequest, + ListLiveConfigsResponse, + ListSlatesRequest, + ListSlatesResponse, + ListVodAdTagDetailsRequest, + ListVodAdTagDetailsResponse, + ListVodConfigsRequest, + ListVodConfigsResponse, + ListVodStitchDetailsRequest, + ListVodStitchDetailsResponse, + OperationMetadata, + UpdateCdnKeyRequest, + UpdateLiveConfigRequest, + UpdateSlateRequest, + UpdateVodConfigRequest, +) +from .vod_configs import ( + GamVodConfig, + VodConfig, +) + +__all__ = ( + 'AdRequest', + 'LiveAdTagDetail', + 'RequestMetadata', + 'ResponseMetadata', + 'VodAdTagDetail', + 'AkamaiCdnKey', + 'CdnKey', + 'GoogleCdnKey', + 'MediaCdnKey', + 'Companion', + 'CompanionAds', + 'HtmlAdResource', + 'IframeAdResource', + 'StaticAdResource', + 'Event', + 'ProgressEvent', + 'FetchOptions', + 'GamLiveConfig', + 'LiveConfig', + 'PrefetchConfig', + 'AdTracking', + 'Interstitials', + 'LiveSession', + 'ManifestOptions', + 'RenditionFilter', + 'VodSession', + 'VodSessionAd', + 'VodSessionAdBreak', + 'VodSessionContent', + 'Slate', + 'AdStitchDetail', + 'VodStitchDetail', + 'CreateCdnKeyRequest', + 'CreateLiveConfigRequest', + 'CreateLiveSessionRequest', + 'CreateSlateRequest', + 'CreateVodConfigRequest', + 'CreateVodSessionRequest', + 'DeleteCdnKeyRequest', + 'DeleteLiveConfigRequest', + 'DeleteSlateRequest', + 'DeleteVodConfigRequest', + 'GetCdnKeyRequest', + 'GetLiveAdTagDetailRequest', + 'GetLiveConfigRequest', + 'GetLiveSessionRequest', + 'GetSlateRequest', + 'GetVodAdTagDetailRequest', + 'GetVodConfigRequest', + 'GetVodSessionRequest', + 'GetVodStitchDetailRequest', + 'ListCdnKeysRequest', + 'ListCdnKeysResponse', + 'ListLiveAdTagDetailsRequest', + 'ListLiveAdTagDetailsResponse', + 'ListLiveConfigsRequest', + 'ListLiveConfigsResponse', + 'ListSlatesRequest', + 'ListSlatesResponse', + 'ListVodAdTagDetailsRequest', + 'ListVodAdTagDetailsResponse', + 'ListVodConfigsRequest', + 'ListVodConfigsResponse', + 'ListVodStitchDetailsRequest', + 'ListVodStitchDetailsResponse', + 'OperationMetadata', + 'UpdateCdnKeyRequest', + 'UpdateLiveConfigRequest', + 'UpdateSlateRequest', + 'UpdateVodConfigRequest', + 'GamVodConfig', + 'VodConfig', +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py new file mode 100644 index 000000000000..74ef768b14b4 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py @@ -0,0 +1,180 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 struct_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.video.stitcher.v1', + manifest={ + 'LiveAdTagDetail', + 'VodAdTagDetail', + 'AdRequest', + 'RequestMetadata', + 'ResponseMetadata', + }, +) + + +class LiveAdTagDetail(proto.Message): + r"""Information related to the details for one ad tag. This + resource is only available for live sessions that do not + implement Google Ad Manager ad insertion. + + Attributes: + name (str): + The resource name in the form of + ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{id}``. + ad_requests (MutableSequence[google.cloud.video.stitcher_v1.types.AdRequest]): + A list of ad requests. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + ad_requests: MutableSequence['AdRequest'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='AdRequest', + ) + + +class VodAdTagDetail(proto.Message): + r"""Information related to the details for one ad tag. This + resource is only available for VOD sessions that do not + implement Google Ad Manager ad insertion. + + Attributes: + name (str): + The name of the ad tag detail for the specified VOD session, + in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{id}``. + ad_requests (MutableSequence[google.cloud.video.stitcher_v1.types.AdRequest]): + A list of ad requests for one ad tag. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + ad_requests: MutableSequence['AdRequest'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='AdRequest', + ) + + +class AdRequest(proto.Message): + r"""Details of an ad request to an ad server. + + Attributes: + uri (str): + The ad tag URI processed with integrated + macros. + request_metadata (google.cloud.video.stitcher_v1.types.RequestMetadata): + The request metadata used to make the ad + request. + response_metadata (google.cloud.video.stitcher_v1.types.ResponseMetadata): + The response metadata received from the ad + request. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + request_metadata: 'RequestMetadata' = proto.Field( + proto.MESSAGE, + number=2, + message='RequestMetadata', + ) + response_metadata: 'ResponseMetadata' = proto.Field( + proto.MESSAGE, + number=3, + message='ResponseMetadata', + ) + + +class RequestMetadata(proto.Message): + r"""Metadata for an ad request. + + Attributes: + headers (google.protobuf.struct_pb2.Struct): + The HTTP headers of the ad request. + """ + + headers: struct_pb2.Struct = proto.Field( + proto.MESSAGE, + number=1, + message=struct_pb2.Struct, + ) + + +class ResponseMetadata(proto.Message): + r"""Metadata for the response of an ad request. + + Attributes: + error (str): + Error message received when making the ad + request. + headers (google.protobuf.struct_pb2.Struct): + Headers from the response. + status_code (str): + Status code for the response. + size_bytes (int): + Size in bytes of the response. + duration (google.protobuf.duration_pb2.Duration): + Total time elapsed for the response. + body (str): + The body of the response. + """ + + error: str = proto.Field( + proto.STRING, + number=1, + ) + headers: struct_pb2.Struct = proto.Field( + proto.MESSAGE, + number=2, + message=struct_pb2.Struct, + ) + status_code: str = proto.Field( + proto.STRING, + number=3, + ) + size_bytes: int = proto.Field( + proto.INT32, + number=4, + ) + duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=5, + message=duration_pb2.Duration, + ) + body: str = proto.Field( + proto.STRING, + number=6, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py new file mode 100644 index 000000000000..c9cf7e3a0453 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py @@ -0,0 +1,182 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher.v1', + manifest={ + 'CdnKey', + 'GoogleCdnKey', + 'AkamaiCdnKey', + 'MediaCdnKey', + }, +) + + +class CdnKey(proto.Message): + r"""Configuration for a CDN key. Used by the Video Stitcher + to sign URIs for fetching video manifests and signing media + segments for playback. + + 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: + google_cdn_key (google.cloud.video.stitcher_v1.types.GoogleCdnKey): + The configuration for a Google Cloud CDN key. + + This field is a member of `oneof`_ ``cdn_key_config``. + akamai_cdn_key (google.cloud.video.stitcher_v1.types.AkamaiCdnKey): + The configuration for an Akamai CDN key. + + This field is a member of `oneof`_ ``cdn_key_config``. + media_cdn_key (google.cloud.video.stitcher_v1.types.MediaCdnKey): + The configuration for a Media CDN key. + + This field is a member of `oneof`_ ``cdn_key_config``. + name (str): + The resource name of the CDN key, in the form of + ``projects/{project}/locations/{location}/cdnKeys/{id}``. + The name is ignored when creating a CDN key. + hostname (str): + The hostname this key applies to. + """ + + google_cdn_key: 'GoogleCdnKey' = proto.Field( + proto.MESSAGE, + number=5, + oneof='cdn_key_config', + message='GoogleCdnKey', + ) + akamai_cdn_key: 'AkamaiCdnKey' = proto.Field( + proto.MESSAGE, + number=6, + oneof='cdn_key_config', + message='AkamaiCdnKey', + ) + media_cdn_key: 'MediaCdnKey' = proto.Field( + proto.MESSAGE, + number=8, + oneof='cdn_key_config', + message='MediaCdnKey', + ) + name: str = proto.Field( + proto.STRING, + number=1, + ) + hostname: str = proto.Field( + proto.STRING, + number=4, + ) + + +class GoogleCdnKey(proto.Message): + r"""Configuration for a Google Cloud CDN key. + + Attributes: + private_key (bytes): + Input only. Secret for this Google Cloud CDN + key. + key_name (str): + The public name of the Google Cloud CDN key. + """ + + private_key: bytes = proto.Field( + proto.BYTES, + number=1, + ) + key_name: str = proto.Field( + proto.STRING, + number=2, + ) + + +class AkamaiCdnKey(proto.Message): + r"""Configuration for an Akamai CDN key. + + Attributes: + token_key (bytes): + Input only. Token key for the Akamai CDN edge + configuration. + """ + + token_key: bytes = proto.Field( + proto.BYTES, + number=1, + ) + + +class MediaCdnKey(proto.Message): + r"""Configuration for a Media CDN key. + + Attributes: + private_key (bytes): + Input only. 64-byte ed25519 private key for + this Media CDN key. + key_name (str): + The keyset name of the Media CDN key. + token_config (google.cloud.video.stitcher_v1.types.MediaCdnKey.TokenConfig): + Optional. If set, the URL will be signed + using the Media CDN token. Otherwise, the URL + would be signed using the standard Media CDN + signature. + """ + + class TokenConfig(proto.Message): + r"""Configuration for a Media CDN token. + + Attributes: + query_parameter (str): + Optional. The query parameter in which to find the token. + + The name must be 1-64 characters long and match the regular + expression ``[a-zA-Z]([a-zA-Z0-9_-])*`` which means the + first character must be a letter, and all following + characters must be a dash, underscore, letter or digit. + + Defaults to ``edge-cache-token``. + """ + + query_parameter: str = proto.Field( + proto.STRING, + number=1, + ) + + private_key: bytes = proto.Field( + proto.BYTES, + number=1, + ) + key_name: str = proto.Field( + proto.STRING, + number=2, + ) + token_config: TokenConfig = proto.Field( + proto.MESSAGE, + number=3, + message=TokenConfig, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py new file mode 100644 index 000000000000..9b5345703e71 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py @@ -0,0 +1,240 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher_v1.types import events as gcvs_events + + +__protobuf__ = proto.module( + package='google.cloud.video.stitcher.v1', + manifest={ + 'CompanionAds', + 'Companion', + 'HtmlAdResource', + 'IframeAdResource', + 'StaticAdResource', + }, +) + + +class CompanionAds(proto.Message): + r"""Metadata for companion ads. + + Attributes: + display_requirement (google.cloud.video.stitcher_v1.types.CompanionAds.DisplayRequirement): + Indicates how many of the companions should + be displayed with the ad. + companions (MutableSequence[google.cloud.video.stitcher_v1.types.Companion]): + List of companion ads. + """ + class DisplayRequirement(proto.Enum): + r"""Indicates how many of the companions should be displayed with + the ad. + + Values: + DISPLAY_REQUIREMENT_UNSPECIFIED (0): + Required companions are not specified. The + default is ALL. + ALL (1): + All companions are required to be displayed. + ANY (2): + At least one of companions needs to be + displayed. + NONE (3): + All companions are optional for display. + """ + DISPLAY_REQUIREMENT_UNSPECIFIED = 0 + ALL = 1 + ANY = 2 + NONE = 3 + + display_requirement: DisplayRequirement = proto.Field( + proto.ENUM, + number=1, + enum=DisplayRequirement, + ) + companions: MutableSequence['Companion'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='Companion', + ) + + +class Companion(proto.Message): + r"""Metadata for a companion. + + 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: + iframe_ad_resource (google.cloud.video.stitcher_v1.types.IframeAdResource): + The IFrame ad resource associated with the + companion ad. + + This field is a member of `oneof`_ ``ad_resource``. + static_ad_resource (google.cloud.video.stitcher_v1.types.StaticAdResource): + The static ad resource associated with the + companion ad. + + This field is a member of `oneof`_ ``ad_resource``. + html_ad_resource (google.cloud.video.stitcher_v1.types.HtmlAdResource): + The HTML ad resource associated with the + companion ad. + + This field is a member of `oneof`_ ``ad_resource``. + api_framework (str): + The API necessary to communicate with the + creative if available. + height_px (int): + The pixel height of the placement slot for + the intended creative. + width_px (int): + The pixel width of the placement slot for the + intended creative. + asset_height_px (int): + The pixel height of the creative. + expanded_height_px (int): + The maximum pixel height of the creative in + its expanded state. + asset_width_px (int): + The pixel width of the creative. + expanded_width_px (int): + The maximum pixel width of the creative in + its expanded state. + ad_slot_id (str): + The ID used to identify the desired placement + on a publisher's page. Values to be used should + be discussed between publishers and advertisers. + events (MutableSequence[google.cloud.video.stitcher_v1.types.Event]): + The list of tracking events for the + companion. + """ + + iframe_ad_resource: 'IframeAdResource' = proto.Field( + proto.MESSAGE, + number=10, + oneof='ad_resource', + message='IframeAdResource', + ) + static_ad_resource: 'StaticAdResource' = proto.Field( + proto.MESSAGE, + number=11, + oneof='ad_resource', + message='StaticAdResource', + ) + html_ad_resource: 'HtmlAdResource' = proto.Field( + proto.MESSAGE, + number=12, + oneof='ad_resource', + message='HtmlAdResource', + ) + api_framework: str = proto.Field( + proto.STRING, + number=1, + ) + height_px: int = proto.Field( + proto.INT32, + number=2, + ) + width_px: int = proto.Field( + proto.INT32, + number=3, + ) + asset_height_px: int = proto.Field( + proto.INT32, + number=4, + ) + expanded_height_px: int = proto.Field( + proto.INT32, + number=5, + ) + asset_width_px: int = proto.Field( + proto.INT32, + number=6, + ) + expanded_width_px: int = proto.Field( + proto.INT32, + number=7, + ) + ad_slot_id: str = proto.Field( + proto.STRING, + number=8, + ) + events: MutableSequence[gcvs_events.Event] = proto.RepeatedField( + proto.MESSAGE, + number=9, + message=gcvs_events.Event, + ) + + +class HtmlAdResource(proto.Message): + r"""Metadata for an HTML ad resource. + + Attributes: + html_source (str): + The HTML to display for the ad resource. + """ + + html_source: str = proto.Field( + proto.STRING, + number=1, + ) + + +class IframeAdResource(proto.Message): + r"""Metadata for an IFrame ad resource. + + Attributes: + uri (str): + URI source for an IFrame to display for the + ad resource. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + + +class StaticAdResource(proto.Message): + r"""Metadata for a static ad resource. + + Attributes: + uri (str): + URI to the static file for the ad resource. + creative_type (str): + Describes the MIME type of the ad resource. + """ + + uri: str = proto.Field( + proto.STRING, + number=1, + ) + creative_type: str = proto.Field( + proto.STRING, + number=2, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py new file mode 100644 index 000000000000..2a21cab7ce8a --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py @@ -0,0 +1,177 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher.v1', + manifest={ + 'Event', + 'ProgressEvent', + }, +) + + +class Event(proto.Message): + r"""Describes an event and a trigger URI. + + Attributes: + type_ (google.cloud.video.stitcher_v1.types.Event.EventType): + Describes the event that occurred. + uri (str): + The URI to trigger for this event. + id (str): + The ID of the event. + offset (google.protobuf.duration_pb2.Duration): + The offset in seconds if the event type is ``PROGRESS``. + """ + class EventType(proto.Enum): + r"""Describes the event that occurred. + + Values: + EVENT_TYPE_UNSPECIFIED (0): + The event type is unspecified. + CREATIVE_VIEW (1): + First frame of creative ad viewed. + START (2): + Creative ad started. + BREAK_START (3): + Start of an ad break. + BREAK_END (4): + End of an ad break. + IMPRESSION (5): + Impression. + FIRST_QUARTILE (6): + First quartile progress. + MIDPOINT (7): + Midpoint progress. + THIRD_QUARTILE (8): + Third quartile progress. + COMPLETE (9): + Ad progress completed. + PROGRESS (10): + Specific progress event with an offset. + MUTE (11): + Player muted. + UNMUTE (12): + Player unmuted. + PAUSE (13): + Player paused. + CLICK (14): + Click event. + CLICK_THROUGH (15): + Click-through event. + REWIND (16): + Player rewinding. + RESUME (17): + Player resumed. + ERROR (18): + Error event. + EXPAND (21): + Ad expanded to a larger size. + COLLAPSE (22): + Ad collapsed to a smaller size. + CLOSE (24): + Non-linear ad closed. + CLOSE_LINEAR (25): + Linear ad closed. + SKIP (26): + Ad skipped. + ACCEPT_INVITATION (27): + Accept invitation event. + """ + EVENT_TYPE_UNSPECIFIED = 0 + CREATIVE_VIEW = 1 + START = 2 + BREAK_START = 3 + BREAK_END = 4 + IMPRESSION = 5 + FIRST_QUARTILE = 6 + MIDPOINT = 7 + THIRD_QUARTILE = 8 + COMPLETE = 9 + PROGRESS = 10 + MUTE = 11 + UNMUTE = 12 + PAUSE = 13 + CLICK = 14 + CLICK_THROUGH = 15 + REWIND = 16 + RESUME = 17 + ERROR = 18 + EXPAND = 21 + COLLAPSE = 22 + CLOSE = 24 + CLOSE_LINEAR = 25 + SKIP = 26 + ACCEPT_INVITATION = 27 + + type_: EventType = proto.Field( + proto.ENUM, + number=1, + enum=EventType, + ) + uri: str = proto.Field( + proto.STRING, + number=2, + ) + id: str = proto.Field( + proto.STRING, + number=3, + ) + offset: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + + +class ProgressEvent(proto.Message): + r"""Indicates a time in which a list of events should be + triggered during media playback. + + Attributes: + time_offset (google.protobuf.duration_pb2.Duration): + The time when the following tracking events + occurs. The time is in seconds relative to the + start of the VOD asset. + events (MutableSequence[google.cloud.video.stitcher_v1.types.Event]): + The list of progress tracking events for the ad break. These + can be of the following IAB types: ``BREAK_START``, + ``BREAK_END``, ``IMPRESSION``, ``CREATIVE_VIEW``, ``START``, + ``FIRST_QUARTILE``, ``MIDPOINT``, ``THIRD_QUARTILE``, + ``COMPLETE``, ``PROGRESS``. + """ + + time_offset: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + events: MutableSequence['Event'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='Event', + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py new file mode 100644 index 000000000000..ecb323aeaede --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher.v1', + manifest={ + 'FetchOptions', + }, +) + + +class FetchOptions(proto.Message): + r"""Options on how fetches should be made. + + Attributes: + headers (MutableMapping[str, str]): + Custom headers to pass into fetch request. + Headers must have a maximum of 3 key value + pairs. Each key value pair must have a maximum + of 256 characters per key and 256 characters per + value. + """ + + headers: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py new file mode 100644 index 000000000000..3cd95c03ac2d --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py @@ -0,0 +1,236 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher_v1.types import fetch_options +from google.protobuf import duration_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.video.stitcher.v1', + manifest={ + 'AdTracking', + 'LiveConfig', + 'PrefetchConfig', + 'GamLiveConfig', + }, +) + + +class AdTracking(proto.Enum): + r"""Determines the ad tracking policy. + + Values: + AD_TRACKING_UNSPECIFIED (0): + The ad tracking policy is not specified. + CLIENT (1): + Client-side ad tracking is specified. The + client player is expected to trigger playback + and activity events itself. + SERVER (2): + The Video Stitcher API will trigger playback + events on behalf of the client player. + """ + AD_TRACKING_UNSPECIFIED = 0 + CLIENT = 1 + SERVER = 2 + + +class LiveConfig(proto.Message): + r"""Metadata for used to register live configs. + + Attributes: + name (str): + Output only. The resource name of the live config, in the + form of + ``projects/{project}/locations/{location}/liveConfigs/{id}``. + source_uri (str): + Required. Source URI for the live stream + manifest. + ad_tag_uri (str): + The default ad tag associated with this live + stream config. + gam_live_config (google.cloud.video.stitcher_v1.types.GamLiveConfig): + Additional metadata used to register a live + stream with Google Ad Manager (GAM) + state (google.cloud.video.stitcher_v1.types.LiveConfig.State): + Output only. State of the live config. + ad_tracking (google.cloud.video.stitcher_v1.types.AdTracking): + Required. Determines how the ads are tracked. + default_slate (str): + This must refer to a slate in the same project. If Google Ad + Manager (GAM) is used for ads, this string sets the value of + ``slateCreativeId`` in + https://developers.google.com/ad-manager/api/reference/v202211/LiveStreamEventService.LiveStreamEvent#slateCreativeId + stitching_policy (google.cloud.video.stitcher_v1.types.LiveConfig.StitchingPolicy): + Defines the stitcher behavior in case an ad does not align + exactly with the ad break boundaries. If not specified, the + default is ``CUT_CURRENT``. + prefetch_config (google.cloud.video.stitcher_v1.types.PrefetchConfig): + The configuration for prefetching ads. + source_fetch_options (google.cloud.video.stitcher_v1.types.FetchOptions): + Options for fetching source manifests and + segments. + """ + class State(proto.Enum): + r"""State of the live config. + + Values: + STATE_UNSPECIFIED (0): + State is not specified. + CREATING (1): + Live config is being created. + READY (2): + Live config is ready for use. + DELETING (3): + Live config is queued up for deletion. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + DELETING = 3 + + class StitchingPolicy(proto.Enum): + r"""Defines the ad stitching behavior in case the ad duration does not + align exactly with the ad break boundaries. If not specified, the + default is ``CUT_CURRENT``. + + Values: + STITCHING_POLICY_UNSPECIFIED (0): + Stitching policy is not specified. + CUT_CURRENT (1): + Cuts an ad short and returns to content in + the middle of the ad. + COMPLETE_AD (2): + Finishes stitching the current ad before + returning to content. + """ + STITCHING_POLICY_UNSPECIFIED = 0 + CUT_CURRENT = 1 + COMPLETE_AD = 2 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + source_uri: str = proto.Field( + proto.STRING, + number=2, + ) + ad_tag_uri: str = proto.Field( + proto.STRING, + number=3, + ) + gam_live_config: 'GamLiveConfig' = proto.Field( + proto.MESSAGE, + number=4, + message='GamLiveConfig', + ) + state: State = proto.Field( + proto.ENUM, + number=5, + enum=State, + ) + ad_tracking: 'AdTracking' = proto.Field( + proto.ENUM, + number=6, + enum='AdTracking', + ) + default_slate: str = proto.Field( + proto.STRING, + number=7, + ) + stitching_policy: StitchingPolicy = proto.Field( + proto.ENUM, + number=8, + enum=StitchingPolicy, + ) + prefetch_config: 'PrefetchConfig' = proto.Field( + proto.MESSAGE, + number=10, + message='PrefetchConfig', + ) + source_fetch_options: fetch_options.FetchOptions = proto.Field( + proto.MESSAGE, + number=16, + message=fetch_options.FetchOptions, + ) + + +class PrefetchConfig(proto.Message): + r"""The configuration for prefetch ads. + + Attributes: + enabled (bool): + Required. Indicates whether the option to + prefetch ad requests is enabled. + initial_ad_request_duration (google.protobuf.duration_pb2.Duration): + The duration in seconds of the part of the + break to be prefetched. This field is only + relevant if prefetch is enabled. You should set + this duration to as long as possible to increase + the benefits of prefetching, but not longer than + the shortest ad break expected. For example, for + a live event with 30s and 60s ad breaks, the + initial duration should be set to 30s. + """ + + enabled: bool = proto.Field( + proto.BOOL, + number=1, + ) + initial_ad_request_duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + + +class GamLiveConfig(proto.Message): + r"""Metadata used to register a live stream with Google Ad + Manager (GAM) + + Attributes: + network_code (str): + Required. Ad Manager network code to + associate with the live config. + asset_key (str): + Output only. The asset key identifier + generated for the live config. + custom_asset_key (str): + Output only. The custom asset key identifier + generated for the live config. + """ + + network_code: str = proto.Field( + proto.STRING, + number=1, + ) + asset_key: str = proto.Field( + proto.STRING, + number=2, + ) + custom_asset_key: str = proto.Field( + proto.STRING, + number=3, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py new file mode 100644 index 000000000000..55e17f4410c1 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py @@ -0,0 +1,452 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher_v1.types import companions +from google.cloud.video.stitcher_v1.types import events +from google.cloud.video.stitcher_v1.types import live_configs +from google.protobuf import duration_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.video.stitcher.v1', + manifest={ + 'VodSession', + 'Interstitials', + 'VodSessionAd', + 'VodSessionContent', + 'VodSessionAdBreak', + 'LiveSession', + 'ManifestOptions', + 'RenditionFilter', + }, +) + + +class VodSession(proto.Message): + r"""Metadata for a VOD session. The session expires 4 hours after + its creation. + + Attributes: + name (str): + Output only. The name of the VOD session, in the form of + ``projects/{project_number}/locations/{location}/vodSessions/{id}``. + interstitials (google.cloud.video.stitcher_v1.types.Interstitials): + Output only. Metadata of what was stitched + into the content. + play_uri (str): + Output only. The playback URI of the stitched + content. + source_uri (str): + URI of the media to stitch. For most use cases, you should + create a + [VodConfig][google.cloud.video.stitcher.v1.VodConfig] with + this information rather than setting this field directly. + ad_tag_uri (str): + Ad tag URI. For most use cases, you should create a + [VodConfig][google.cloud.video.stitcher.v1.VodConfig] with + this information rather than setting this field directly. + ad_tag_macro_map (MutableMapping[str, str]): + Key value pairs for ad tag macro replacement, only available + for VOD sessions that do not implement Google Ad manager ad + insertion. If the specified ad tag URI has macros, this + field provides the mapping to the value that will replace + the macro in the ad tag URI. + + Macros are designated by square brackets, for example: + + Ad tag URI: + ``"https://doubleclick.google.com/ad/1?geo_id=[geoId]"`` + + Ad tag macro map: ``{"geoId": "123"}`` + + Fully qualified ad tag: + ``"https://doubleclick.google.com/ad/1?geo_id=123"`` + manifest_options (google.cloud.video.stitcher_v1.types.ManifestOptions): + Additional options that affect the output of + the manifest. + asset_id (str): + Output only. The generated ID of the + VodSession's source media. + ad_tracking (google.cloud.video.stitcher_v1.types.AdTracking): + Required. Determines how the ad should be + tracked. + gam_settings (google.cloud.video.stitcher_v1.types.VodSession.GamSettings): + This field should be set with appropriate + values if GAM is being used for ads. + vod_config (str): + The resource name of the VOD config for this session, in the + form of + ``projects/{project}/locations/{location}/vodConfigs/{id}``. + """ + + class GamSettings(proto.Message): + r"""Defines fields related to Google Ad Manager (GAM). This + should be set if GAM is being used for ads. + + Attributes: + network_code (str): + Required. Ad Manager network code. + stream_id (str): + Required. The stream ID generated by Ad + Manager. + """ + + network_code: str = proto.Field( + proto.STRING, + number=1, + ) + stream_id: str = proto.Field( + proto.STRING, + number=2, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + interstitials: 'Interstitials' = proto.Field( + proto.MESSAGE, + number=2, + message='Interstitials', + ) + play_uri: str = proto.Field( + proto.STRING, + number=4, + ) + source_uri: str = proto.Field( + proto.STRING, + number=5, + ) + ad_tag_uri: str = proto.Field( + proto.STRING, + number=6, + ) + ad_tag_macro_map: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) + manifest_options: 'ManifestOptions' = proto.Field( + proto.MESSAGE, + number=9, + message='ManifestOptions', + ) + asset_id: str = proto.Field( + proto.STRING, + number=10, + ) + ad_tracking: live_configs.AdTracking = proto.Field( + proto.ENUM, + number=11, + enum=live_configs.AdTracking, + ) + gam_settings: GamSettings = proto.Field( + proto.MESSAGE, + number=13, + message=GamSettings, + ) + vod_config: str = proto.Field( + proto.STRING, + number=14, + ) + + +class Interstitials(proto.Message): + r"""Describes what was stitched into a VOD session's manifest. + + Attributes: + ad_breaks (MutableSequence[google.cloud.video.stitcher_v1.types.VodSessionAdBreak]): + List of ad breaks ordered by time. + session_content (google.cloud.video.stitcher_v1.types.VodSessionContent): + Information related to the content of the VOD + session. + """ + + ad_breaks: MutableSequence['VodSessionAdBreak'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='VodSessionAdBreak', + ) + session_content: 'VodSessionContent' = proto.Field( + proto.MESSAGE, + number=2, + message='VodSessionContent', + ) + + +class VodSessionAd(proto.Message): + r"""Metadata for an inserted ad in a VOD session. + + Attributes: + duration (google.protobuf.duration_pb2.Duration): + Duration in seconds of the ad. + companion_ads (google.cloud.video.stitcher_v1.types.CompanionAds): + Metadata of companion ads associated with the + ad. + activity_events (MutableSequence[google.cloud.video.stitcher_v1.types.Event]): + The list of progress tracking events for the ad break. These + can be of the following IAB types: ``MUTE``, ``UNMUTE``, + ``PAUSE``, ``CLICK``, ``CLICK_THROUGH``, ``REWIND``, + ``RESUME``, ``ERROR``, ``FULLSCREEN``, ``EXIT_FULLSCREEN``, + ``EXPAND``, ``COLLAPSE``, ``ACCEPT_INVITATION_LINEAR``, + ``CLOSE_LINEAR``, ``SKIP``. + """ + + duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + companion_ads: companions.CompanionAds = proto.Field( + proto.MESSAGE, + number=2, + message=companions.CompanionAds, + ) + activity_events: MutableSequence[events.Event] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=events.Event, + ) + + +class VodSessionContent(proto.Message): + r"""Metadata for the entire stitched content in a VOD session. + + Attributes: + duration (google.protobuf.duration_pb2.Duration): + The total duration in seconds of the content + including the ads stitched in. + """ + + duration: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) + + +class VodSessionAdBreak(proto.Message): + r"""Metadata for an inserted ad break. + + Attributes: + progress_events (MutableSequence[google.cloud.video.stitcher_v1.types.ProgressEvent]): + List of events that are expected to be + triggered, ordered by time. + ads (MutableSequence[google.cloud.video.stitcher_v1.types.VodSessionAd]): + Ordered list of ads stitched into the ad + break. + end_time_offset (google.protobuf.duration_pb2.Duration): + Ad break end time in seconds relative to the + start of the VOD asset. + start_time_offset (google.protobuf.duration_pb2.Duration): + Ad break start time in seconds relative to + the start of the VOD asset. + """ + + progress_events: MutableSequence[events.ProgressEvent] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=events.ProgressEvent, + ) + ads: MutableSequence['VodSessionAd'] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message='VodSessionAd', + ) + end_time_offset: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + start_time_offset: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + + +class LiveSession(proto.Message): + r"""Metadata for a live session. The session expires 5 minutes + after the client stops fetching the session's playlists. + + Attributes: + name (str): + Output only. The name of the live session, in the form of + ``projects/{project}/locations/{location}/liveSessions/{id}``. + play_uri (str): + Output only. The URI to play the live + session's ad-stitched stream. + ad_tag_macros (MutableMapping[str, str]): + Key value pairs for ad tag macro replacement, only available + for live sessions that do not implement Google Ad manager ad + insertion. If the specified ad tag URI has macros, this + field provides the mapping to the value that will replace + the macro in the ad tag URI. + + Macros are designated by square brackets, for example: + + Ad tag URI: + "https://doubleclick.google.com/ad/1?geo_id=[geoId]" + + Ad tag macros: ``{"geoId": "123"}`` + + Fully qualified ad tag: + ``"https://doubleclick.google.com/ad/1?geo_id=123"`` + manifest_options (google.cloud.video.stitcher_v1.types.ManifestOptions): + Additional options that affect the output of + the manifest. + gam_settings (google.cloud.video.stitcher_v1.types.LiveSession.GamSettings): + This field should be set with appropriate + values if GAM is being used for ads. + live_config (str): + Required. The resource name of the live config for this + session, in the form of + ``projects/{project}/locations/{location}/liveConfigs/{id}``. + ad_tracking (google.cloud.video.stitcher_v1.types.AdTracking): + Determines how the ad should be tracked. This + overrides the value set in the live config for + this session. + """ + + class GamSettings(proto.Message): + r"""Defines fields related to Google Ad Manager (GAM). + + Attributes: + stream_id (str): + Required. The stream ID generated by Ad + Manager. This must be set if GAM is being used + for ads and the session uses client-side ad + tracking. + targeting_parameters (MutableMapping[str, str]): + `Targeting + parameters `__ + to send to Ad Manager to generate a stream ID. This should + only be set if the session uses server-side ad tracking. + """ + + stream_id: str = proto.Field( + proto.STRING, + number=1, + ) + targeting_parameters: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + play_uri: str = proto.Field( + proto.STRING, + number=2, + ) + ad_tag_macros: MutableMapping[str, str] = proto.MapField( + proto.STRING, + proto.STRING, + number=6, + ) + manifest_options: 'ManifestOptions' = proto.Field( + proto.MESSAGE, + number=10, + message='ManifestOptions', + ) + gam_settings: GamSettings = proto.Field( + proto.MESSAGE, + number=15, + message=GamSettings, + ) + live_config: str = proto.Field( + proto.STRING, + number=16, + ) + ad_tracking: live_configs.AdTracking = proto.Field( + proto.ENUM, + number=17, + enum=live_configs.AdTracking, + ) + + +class ManifestOptions(proto.Message): + r"""Options for manifest generation. + + Attributes: + include_renditions (MutableSequence[google.cloud.video.stitcher_v1.types.RenditionFilter]): + If specified, the output manifest will only + return renditions matching the specified + filters. + bitrate_order (google.cloud.video.stitcher_v1.types.ManifestOptions.OrderPolicy): + If specified, the output manifest will orders + the video and muxed renditions by bitrate + according to the ordering policy. + """ + class OrderPolicy(proto.Enum): + r"""Defines the ordering policy during manifest generation. + + Values: + ORDER_POLICY_UNSPECIFIED (0): + Ordering policy is not specified. + ASCENDING (1): + Order by ascending. + DESCENDING (2): + Order by descending. + """ + ORDER_POLICY_UNSPECIFIED = 0 + ASCENDING = 1 + DESCENDING = 2 + + include_renditions: MutableSequence['RenditionFilter'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='RenditionFilter', + ) + bitrate_order: OrderPolicy = proto.Field( + proto.ENUM, + number=2, + enum=OrderPolicy, + ) + + +class RenditionFilter(proto.Message): + r"""Filters for a video or muxed redition. + + Attributes: + bitrate_bps (int): + Bitrate in bits per second for the rendition. + If set, only renditions with the exact bitrate + will match. + codecs (str): + Codecs for the rendition. If set, only + renditions with the exact value will match. + """ + + bitrate_bps: int = proto.Field( + proto.INT32, + number=1, + ) + codecs: str = proto.Field( + proto.STRING, + number=2, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py new file mode 100644 index 000000000000..6966b8630ab0 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher.v1', + manifest={ + 'Slate', + }, +) + + +class Slate(proto.Message): + r"""Slate object + + Attributes: + name (str): + Output only. The name of the slate, in the form of + ``projects/{project_number}/locations/{location}/slates/{id}``. + uri (str): + The URI to fetch the source content for the + slate. This URI must return an MP4 video with at + least one audio track. + gam_slate (google.cloud.video.stitcher_v1.types.Slate.GamSlate): + gam_slate has all the GAM-related attributes of slates. + """ + + class GamSlate(proto.Message): + r"""GamSlate object has Google Ad Manager (GAM) related + properties for the slate. + + Attributes: + network_code (str): + Required. Ad Manager network code to + associate with the live config. + gam_slate_id (int): + Output only. The identifier generated for the + slate by GAM. + """ + + network_code: str = proto.Field( + proto.STRING, + number=1, + ) + gam_slate_id: int = proto.Field( + proto.INT64, + number=2, + ) + + name: str = proto.Field( + proto.STRING, + number=1, + ) + uri: str = proto.Field( + proto.STRING, + number=2, + ) + gam_slate: GamSlate = proto.Field( + proto.MESSAGE, + number=3, + message=GamSlate, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py new file mode 100644 index 000000000000..95babe6f6f28 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 struct_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.video.stitcher.v1', + manifest={ + 'VodStitchDetail', + 'AdStitchDetail', + }, +) + + +class VodStitchDetail(proto.Message): + r"""Information related to the interstitial of a VOD session. + This resource is only available for VOD sessions that do not + implement Google Ad Manager ad insertion. + + Attributes: + name (str): + The name of the stitch detail in the specified VOD session, + in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. + ad_stitch_details (MutableSequence[google.cloud.video.stitcher_v1.types.AdStitchDetail]): + A list of ad processing details for the + fetched ad playlist. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + ad_stitch_details: MutableSequence['AdStitchDetail'] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message='AdStitchDetail', + ) + + +class AdStitchDetail(proto.Message): + r"""Metadata for a stitched ad. + + Attributes: + ad_break_id (str): + Required. The ad break ID of the processed + ad. + ad_id (str): + Required. The ad ID of the processed ad. + ad_time_offset (google.protobuf.duration_pb2.Duration): + Required. The time offset of the processed + ad. + skip_reason (str): + Optional. Indicates the reason why the ad has + been skipped. + media (MutableMapping[str, google.protobuf.struct_pb2.Value]): + Optional. The metadata of the chosen media + file for the ad. + """ + + ad_break_id: str = proto.Field( + proto.STRING, + number=1, + ) + ad_id: str = proto.Field( + proto.STRING, + number=2, + ) + ad_time_offset: duration_pb2.Duration = proto.Field( + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + skip_reason: str = proto.Field( + proto.STRING, + number=4, + ) + media: MutableMapping[str, struct_pb2.Value] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=5, + message=struct_pb2.Value, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py new file mode 100644 index 000000000000..a2f42edd7cae --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py @@ -0,0 +1,1124 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys as gcvs_cdn_keys +from google.cloud.video.stitcher_v1.types import live_configs as gcvs_live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates as gcvs_slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import vod_configs as gcvs_vod_configs +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.video.stitcher.v1', + manifest={ + 'CreateCdnKeyRequest', + 'ListCdnKeysRequest', + 'ListCdnKeysResponse', + 'GetCdnKeyRequest', + 'DeleteCdnKeyRequest', + 'UpdateCdnKeyRequest', + 'CreateVodSessionRequest', + 'GetVodSessionRequest', + 'ListVodStitchDetailsRequest', + 'ListVodStitchDetailsResponse', + 'GetVodStitchDetailRequest', + 'ListVodAdTagDetailsRequest', + 'ListVodAdTagDetailsResponse', + 'GetVodAdTagDetailRequest', + 'ListLiveAdTagDetailsRequest', + 'ListLiveAdTagDetailsResponse', + 'GetLiveAdTagDetailRequest', + 'CreateSlateRequest', + 'GetSlateRequest', + 'ListSlatesRequest', + 'ListSlatesResponse', + 'UpdateSlateRequest', + 'DeleteSlateRequest', + 'CreateLiveSessionRequest', + 'GetLiveSessionRequest', + 'CreateLiveConfigRequest', + 'ListLiveConfigsRequest', + 'ListLiveConfigsResponse', + 'GetLiveConfigRequest', + 'DeleteLiveConfigRequest', + 'UpdateLiveConfigRequest', + 'CreateVodConfigRequest', + 'ListVodConfigsRequest', + 'ListVodConfigsResponse', + 'GetVodConfigRequest', + 'DeleteVodConfigRequest', + 'UpdateVodConfigRequest', + 'OperationMetadata', + }, +) + + +class CreateCdnKeyRequest(proto.Message): + r"""Request message for VideoStitcherService.createCdnKey. + + Attributes: + parent (str): + Required. The project in which the CDN key should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): + Required. The CDN key resource to create. + cdn_key_id (str): + Required. The ID to use for the CDN key, + which will become the final component of the CDN + key's resource name. + + This value should conform to RFC-1034, which + restricts to lower-case letters, numbers, and + hyphen, with the first character a letter, the + last a letter or a number, and a 63 character + maximum. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + cdn_key: gcvs_cdn_keys.CdnKey = proto.Field( + proto.MESSAGE, + number=2, + message=gcvs_cdn_keys.CdnKey, + ) + cdn_key_id: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListCdnKeysRequest(proto.Message): + r"""Request message for VideoStitcherService.listCdnKeys. + + Attributes: + parent (str): + Required. The project that contains the list of CDN keys, in + the form of + ``projects/{project_number}/locations/{location}``. + page_size (int): + Requested page size. Server may return fewer + items than requested. If unspecified, server + will pick an appropriate default. + page_token (str): + A token identifying a page of results the + server should return. + filter (str): + Filtering results + order_by (str): + Hint for how to order the results + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListCdnKeysResponse(proto.Message): + r"""Response message for VideoStitcher.ListCdnKeys. + + Attributes: + cdn_keys (MutableSequence[google.cloud.video.stitcher_v1.types.CdnKey]): + List of CDN keys. + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + cdn_keys: MutableSequence[gcvs_cdn_keys.CdnKey] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcvs_cdn_keys.CdnKey, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetCdnKeyRequest(proto.Message): + r"""Request message for VideoStitcherService.getCdnKey. + + Attributes: + name (str): + Required. The name of the CDN key to be retrieved, in the + form of + ``projects/{project}/locations/{location}/cdnKeys/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteCdnKeyRequest(proto.Message): + r"""Request message for VideoStitcherService.deleteCdnKey. + + Attributes: + name (str): + Required. The name of the CDN key to be deleted, in the form + of + ``projects/{project_number}/locations/{location}/cdnKeys/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateCdnKeyRequest(proto.Message): + r"""Request message for VideoStitcherService.updateCdnKey. + + Attributes: + cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): + Required. The CDN key resource which replaces + the resource on the server. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + cdn_key: gcvs_cdn_keys.CdnKey = proto.Field( + proto.MESSAGE, + number=1, + message=gcvs_cdn_keys.CdnKey, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class CreateVodSessionRequest(proto.Message): + r"""Request message for VideoStitcherService.createVodSession + + Attributes: + parent (str): + Required. The project and location in which the VOD session + should be created, in the form of + ``projects/{project_number}/locations/{location}``. + vod_session (google.cloud.video.stitcher_v1.types.VodSession): + Required. Parameters for creating a session. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + vod_session: sessions.VodSession = proto.Field( + proto.MESSAGE, + number=2, + message=sessions.VodSession, + ) + + +class GetVodSessionRequest(proto.Message): + r"""Request message for VideoStitcherService.getVodSession + + Attributes: + name (str): + Required. The name of the VOD session to be retrieved, in + the form of + ``projects/{project_number}/locations/{location}/vodSessions/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListVodStitchDetailsRequest(proto.Message): + r"""Request message for + VideoStitcherService.listVodStitchDetails. + + Attributes: + parent (str): + Required. The VOD session where the stitch details belong + to, in the form of + ``projects/{project}/locations/{location}/vodSessions/{id}``. + page_size (int): + The maximum number of items to return. + page_token (str): + The next_page_token value returned from a previous List + request, if any. + """ + + 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 ListVodStitchDetailsResponse(proto.Message): + r"""Response message for + VideoStitcherService.listVodStitchDetails. + + Attributes: + vod_stitch_details (MutableSequence[google.cloud.video.stitcher_v1.types.VodStitchDetail]): + A List of stitch Details. + next_page_token (str): + The pagination token. + """ + + @property + def raw_page(self): + return self + + vod_stitch_details: MutableSequence[stitch_details.VodStitchDetail] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=stitch_details.VodStitchDetail, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetVodStitchDetailRequest(proto.Message): + r"""Request message for VideoStitcherService.getVodStitchDetail. + + Attributes: + name (str): + Required. The name of the stitch detail in the specified VOD + session, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListVodAdTagDetailsRequest(proto.Message): + r"""Request message for VideoStitcherService.listVodAdTagDetails. + + Attributes: + parent (str): + Required. The VOD session which the ad tag details belong + to, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}``. + page_size (int): + The maximum number of items to return. + page_token (str): + The next_page_token value returned from a previous List + request, if any. + """ + + 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 ListVodAdTagDetailsResponse(proto.Message): + r"""Response message for + VideoStitcherService.listVodAdTagDetails. + + Attributes: + vod_ad_tag_details (MutableSequence[google.cloud.video.stitcher_v1.types.VodAdTagDetail]): + A List of ad tag details. + next_page_token (str): + The pagination token. + """ + + @property + def raw_page(self): + return self + + vod_ad_tag_details: MutableSequence[ad_tag_details.VodAdTagDetail] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=ad_tag_details.VodAdTagDetail, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetVodAdTagDetailRequest(proto.Message): + r"""Request message for VideoStitcherService.getVodAdTagDetail + + Attributes: + name (str): + Required. The name of the ad tag detail for the specified + VOD session, in the form of + ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{vod_ad_tag_detail}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListLiveAdTagDetailsRequest(proto.Message): + r"""Request message for + VideoStitcherService.listLiveAdTagDetails. + + Attributes: + parent (str): + Required. The resource parent in the form of + ``projects/{project}/locations/{location}/liveSessions/{live_session}``. + page_size (int): + The maximum number of items to return. + page_token (str): + The pagination token 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 ListLiveAdTagDetailsResponse(proto.Message): + r"""Response message for + VideoStitcherService.listLiveAdTagDetails. + + Attributes: + live_ad_tag_details (MutableSequence[google.cloud.video.stitcher_v1.types.LiveAdTagDetail]): + A list of live session ad tag details. + next_page_token (str): + The pagination token. + """ + + @property + def raw_page(self): + return self + + live_ad_tag_details: MutableSequence[ad_tag_details.LiveAdTagDetail] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=ad_tag_details.LiveAdTagDetail, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetLiveAdTagDetailRequest(proto.Message): + r"""Request message for VideoStitcherService.getLiveAdTagDetail + + Attributes: + name (str): + Required. The resource name in the form of + ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateSlateRequest(proto.Message): + r"""Request message for VideoStitcherService.createSlate. + + Attributes: + parent (str): + Required. The project in which the slate should be created, + in the form of + ``projects/{project_number}/locations/{location}``. + slate_id (str): + Required. The unique identifier for the + slate. This value should conform to RFC-1034, + which restricts to lower-case letters, numbers, + and hyphen, with the first character a letter, + the last a letter or a number, and a 63 + character maximum. + slate (google.cloud.video.stitcher_v1.types.Slate): + Required. The slate to create. + request_id (str): + A request ID to identify requests. Specify a unique request + ID so that if you must retry your request, the server will + know to ignore the request if it has already been completed. + The server will guarantee that for at least 60 minutes since + the first request. + + For example, consider a situation where you make an initial + request and the request times out. If you make the request + again with the same request ID, the server can check if + original operation with the same request ID was received, + and if so, will ignore the second request. This prevents + clients from accidentally creating duplicate commitments. + + The request ID must be a valid UUID with the exception that + zero UUID is not supported + ``(00000000-0000-0000-0000-000000000000)``. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + slate_id: str = proto.Field( + proto.STRING, + number=2, + ) + slate: gcvs_slates.Slate = proto.Field( + proto.MESSAGE, + number=3, + message=gcvs_slates.Slate, + ) + request_id: str = proto.Field( + proto.STRING, + number=4, + ) + + +class GetSlateRequest(proto.Message): + r"""Request message for VideoStitcherService.getSlate. + + Attributes: + name (str): + Required. The name of the slate to be retrieved, of the + slate, in the form of + ``projects/{project_number}/locations/{location}/slates/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class ListSlatesRequest(proto.Message): + r"""Request message for VideoStitcherService.listSlates. + + Attributes: + parent (str): + Required. The project to list slates, in the form of + ``projects/{project_number}/locations/{location}``. + page_size (int): + Requested page size. Server may return fewer + items than requested. If unspecified, server + will pick an appropriate default. + page_token (str): + A token identifying a page of results the + server should return. + filter (str): + Filtering results + order_by (str): + Hint for how to order the results + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListSlatesResponse(proto.Message): + r"""Response message for VideoStitcherService.listSlates. + + Attributes: + slates (MutableSequence[google.cloud.video.stitcher_v1.types.Slate]): + The list of slates + next_page_token (str): + A token identifying a page of results the + server should return. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + slates: MutableSequence[gcvs_slates.Slate] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcvs_slates.Slate, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class UpdateSlateRequest(proto.Message): + r"""Request message for VideoStitcherService.updateSlate. + + Attributes: + slate (google.cloud.video.stitcher_v1.types.Slate): + Required. The resource with updated fields. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask which specifies + fields which should be updated. + """ + + slate: gcvs_slates.Slate = proto.Field( + proto.MESSAGE, + number=1, + message=gcvs_slates.Slate, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteSlateRequest(proto.Message): + r"""Request message for VideoStitcherService.deleteSlate. + + Attributes: + name (str): + Required. The name of the slate to be deleted, in the form + of + ``projects/{project_number}/locations/{location}/slates/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateLiveSessionRequest(proto.Message): + r"""Request message for VideoStitcherService.createLiveSession. + + Attributes: + parent (str): + Required. The project and location in which the live session + should be created, in the form of + ``projects/{project_number}/locations/{location}``. + live_session (google.cloud.video.stitcher_v1.types.LiveSession): + Required. Parameters for creating a live + session. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + live_session: sessions.LiveSession = proto.Field( + proto.MESSAGE, + number=2, + message=sessions.LiveSession, + ) + + +class GetLiveSessionRequest(proto.Message): + r"""Request message for VideoStitcherService.getSession. + + Attributes: + name (str): + Required. The name of the live session, in the form of + ``projects/{project_number}/locations/{location}/liveSessions/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateLiveConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.createLiveConfig + + Attributes: + parent (str): + Required. The project in which the live config should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + live_config_id (str): + Required. The unique identifier ID to use for + the live config. + live_config (google.cloud.video.stitcher_v1.types.LiveConfig): + Required. The live config resource to create. + request_id (str): + A request ID to identify requests. Specify a unique request + ID so that if you must retry your request, the server will + know to ignore the request if it has already been completed. + The server will guarantee that for at least 60 minutes since + the first request. + + For example, consider a situation where you make an initial + request and the request times out. If you make the request + again with the same request ID, the server can check if + original operation with the same request ID was received, + and if so, will ignore the second request. This prevents + clients from accidentally creating duplicate commitments. + + The request ID must be a valid UUID with the exception that + zero UUID is not supported + ``(00000000-0000-0000-0000-000000000000)``. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + live_config_id: str = proto.Field( + proto.STRING, + number=2, + ) + live_config: gcvs_live_configs.LiveConfig = proto.Field( + proto.MESSAGE, + number=3, + message=gcvs_live_configs.LiveConfig, + ) + request_id: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListLiveConfigsRequest(proto.Message): + r"""Request message for VideoStitcherService.listLiveConfig. + + Attributes: + parent (str): + Required. The project that contains the list of live + configs, in the form of + ``projects/{project_number}/locations/{location}``. + page_size (int): + The maximum number of items to return. + page_token (str): + The next_page_token value returned from a previous List + request, if any. + filter (str): + Optional. The filter to apply to list results (see + `Filtering `__). + order_by (str): + Optional. Specifies the ordering of results following `Cloud + API + syntax `__. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListLiveConfigsResponse(proto.Message): + r"""Response message for VideoStitcher.ListLiveConfig. + + Attributes: + live_configs (MutableSequence[google.cloud.video.stitcher_v1.types.LiveConfig]): + List of live configs. + next_page_token (str): + The pagination token. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + live_configs: MutableSequence[gcvs_live_configs.LiveConfig] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcvs_live_configs.LiveConfig, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetLiveConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.getLiveConfig. + + Attributes: + name (str): + Required. The name of the live config to be retrieved, in + the form of + ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteLiveConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.deleteLiveConfig. + + Attributes: + name (str): + Required. The name of the live config to be deleted, in the + form of + ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateLiveConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.updateLiveConfig. + + Attributes: + live_config (google.cloud.video.stitcher_v1.types.LiveConfig): + Required. The LiveConfig resource which + replaces the resource on the server. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + live_config: gcvs_live_configs.LiveConfig = proto.Field( + proto.MESSAGE, + number=1, + message=gcvs_live_configs.LiveConfig, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class CreateVodConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.createVodConfig + + Attributes: + parent (str): + Required. The project in which the VOD config should be + created, in the form of + ``projects/{project_number}/locations/{location}``. + vod_config_id (str): + Required. The unique identifier ID to use for + the VOD config. + vod_config (google.cloud.video.stitcher_v1.types.VodConfig): + Required. The VOD config resource to create. + request_id (str): + Optional. A request ID to identify requests. Specify a + unique request ID so that if you must retry your request, + the server will know to ignore the request if it has already + been completed. The server will guarantee that for at least + 60 minutes since the first request. + + For example, consider a situation where you make an initial + request and the request times out. If you make the request + again with the same request ID, the server can check if + original operation with the same request ID was received, + and if so, will ignore the second request. This prevents + clients from accidentally creating duplicate commitments. + + The request ID must be a valid UUID with the exception that + zero UUID is not supported + ``(00000000-0000-0000-0000-000000000000)``. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + vod_config_id: str = proto.Field( + proto.STRING, + number=2, + ) + vod_config: gcvs_vod_configs.VodConfig = proto.Field( + proto.MESSAGE, + number=3, + message=gcvs_vod_configs.VodConfig, + ) + request_id: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListVodConfigsRequest(proto.Message): + r"""Request message for VideoStitcherService.listVodConfig. + + Attributes: + parent (str): + Required. The project that contains the list of VOD configs, + in the form of + ``projects/{project_number}/locations/{location}``. + page_size (int): + Optional. The maximum number of items to + return. + page_token (str): + Optional. The next_page_token value returned from a previous + List request, if any. + filter (str): + Optional. The filter to apply to list results (see + `Filtering `__). + order_by (str): + Optional. Specifies the ordering of results following `Cloud + API + syntax `__. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + filter: str = proto.Field( + proto.STRING, + number=4, + ) + order_by: str = proto.Field( + proto.STRING, + number=5, + ) + + +class ListVodConfigsResponse(proto.Message): + r"""Response message for VideoStitcher.ListVodConfig. + + Attributes: + vod_configs (MutableSequence[google.cloud.video.stitcher_v1.types.VodConfig]): + List of VOD configs. + next_page_token (str): + The pagination token. + unreachable (MutableSequence[str]): + Locations that could not be reached. + """ + + @property + def raw_page(self): + return self + + vod_configs: MutableSequence[gcvs_vod_configs.VodConfig] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gcvs_vod_configs.VodConfig, + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + unreachable: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) + + +class GetVodConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.getVodConfig. + + Attributes: + name (str): + Required. The name of the VOD config to be retrieved, in the + form of + ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class DeleteVodConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.deleteVodConfig. + + Attributes: + name (str): + Required. The name of the VOD config to be deleted, in the + form of + ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateVodConfigRequest(proto.Message): + r"""Request message for VideoStitcherService.updateVodConfig. + + Attributes: + vod_config (google.cloud.video.stitcher_v1.types.VodConfig): + Required. The VOD config resource which + replaces the resource on the server. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. The update mask applies to the resource. For the + ``FieldMask`` definition, see + https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + """ + + vod_config: gcvs_vod_configs.VodConfig = proto.Field( + proto.MESSAGE, + number=1, + message=gcvs_vod_configs.VodConfig, + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class OperationMetadata(proto.Message): + r"""Represents the metadata of the long-running operation. + + Attributes: + create_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation was created. + end_time (google.protobuf.timestamp_pb2.Timestamp): + The time the operation finished running. + target (str): + Server-defined resource path for the target + of the operation. + verb (str): + Name of the verb executed by the operation. + """ + + create_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + end_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + target: str = proto.Field( + proto.STRING, + number=3, + ) + verb: str = proto.Field( + proto.STRING, + number=4, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py new file mode 100644 index 000000000000..be31d4de3b26 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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.video.stitcher_v1.types import fetch_options + + +__protobuf__ = proto.module( + package='google.cloud.video.stitcher.v1', + manifest={ + 'VodConfig', + 'GamVodConfig', + }, +) + + +class VodConfig(proto.Message): + r"""Metadata used to register VOD configs. + + Attributes: + name (str): + Output only. The resource name of the VOD config, in the + form of + ``projects/{project}/locations/{location}/vodConfigs/{id}``. + source_uri (str): + Required. Source URI for the VOD stream + manifest. + ad_tag_uri (str): + Required. The default ad tag associated with + this VOD config. + gam_vod_config (google.cloud.video.stitcher_v1.types.GamVodConfig): + Optional. Google Ad Manager (GAM) metadata. + state (google.cloud.video.stitcher_v1.types.VodConfig.State): + Output only. State of the VOD config. + source_fetch_options (google.cloud.video.stitcher_v1.types.FetchOptions): + Options for fetching source manifests and + segments. + """ + class State(proto.Enum): + r"""State of the VOD config. + + Values: + STATE_UNSPECIFIED (0): + State is not specified. + CREATING (1): + VOD config is being created. + READY (2): + VOD config is ready for use. + DELETING (3): + VOD config is queued up for deletion. + """ + STATE_UNSPECIFIED = 0 + CREATING = 1 + READY = 2 + DELETING = 3 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + source_uri: str = proto.Field( + proto.STRING, + number=2, + ) + ad_tag_uri: str = proto.Field( + proto.STRING, + number=3, + ) + gam_vod_config: 'GamVodConfig' = proto.Field( + proto.MESSAGE, + number=4, + message='GamVodConfig', + ) + state: State = proto.Field( + proto.ENUM, + number=5, + enum=State, + ) + source_fetch_options: fetch_options.FetchOptions = proto.Field( + proto.MESSAGE, + number=8, + message=fetch_options.FetchOptions, + ) + + +class GamVodConfig(proto.Message): + r"""Metadata used for GAM ad decisioning. + + Attributes: + network_code (str): + Required. Ad Manager network code to + associate with the VOD config. + """ + + network_code: str = proto.Field( + proto.STRING, + number=1, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini b/owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini new file mode 100644 index 000000000000..574c5aed394b --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.7 +namespace_packages = True diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py b/owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py new file mode 100644 index 000000000000..2f49beb21277 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py @@ -0,0 +1,591 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import pathlib +import re +import shutil + +from typing import Dict, List +import warnings + +import nox + +BLACK_VERSION = "black[jupyter]==23.7.0" +ISORT_VERSION = "isort==5.11.0" + +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] + +ALL_PYTHON = [ + "3.7", + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", + "3.13", +] + +DEFAULT_PYTHON_VERSION = ALL_PYTHON[-1] + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = "google-cloud-video-stitcher" + +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] +UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [] +UNIT_TEST_DEPENDENCIES: List[str] = [] +UNIT_TEST_EXTRAS: List[str] = [] +UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} + +SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_DEPENDENCIES: List[str] = [] +SYSTEM_TEST_EXTRAS: List[str] = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} + +nox.options.sessions = [ + "unit", + "system", + "cover", + "lint", + "lint_setup_py", + "blacken", + "docs", +] + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + + +@nox.session(python=ALL_PYTHON) +def mypy(session): + """Run the type checker.""" + session.install( + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2410): Use the latest version of mypy + "mypy<1.16.0", + "types-requests", + "types-protobuf", + ) + session.install(".") + session.run( + "mypy", + "-p", + "google", + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install("google-cloud-testutils") + session.install(".") + + session.run( + "lower-bound-checker", + "update", + "--package-name", + PACKAGE_NAME, + "--constraints-file", + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install("google-cloud-testutils") + session.install(".") + + session.run( + "lower-bound-checker", + "check", + "--package-name", + PACKAGE_NAME, + "--constraints-file", + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): + """Run linters. + + Returns a failure if the linters find linting errors or sufficiently + serious code quality issues. + """ + session.install("flake8", BLACK_VERSION) + session.run( + "black", + "--check", + *LINT_PATHS, + ) + + session.run("flake8", "google", "tests") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def blacken(session): + """Run black. Format code to uniform standard.""" + session.install(BLACK_VERSION) + session.run( + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint_setup_py(session): + """Verify that setup.py is valid (including RST check).""" + session.install("setuptools", "docutils", "pygments") + session.run("python", "setup.py", "check", "--restructuredtext", "--strict") + + +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + +@nox.session(python=ALL_PYTHON) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def unit(session, protobuf_implementation): + # Install all test dependencies, then install this package in-place. + + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): + session.skip("cpp implementation is not supported in python 3.11+") + + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) + install_unittest_dependencies(session, "-c", constraints_path) + + # TODO(https://github.com/googleapis/synthtool/issues/1976): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + + # Run py.test against the unit tests. + session.run( + "py.test", + "--quiet", + f"--junitxml=unit_{session.python}_sponge_log.xml", + "--cov=google", + "--cov=tests/unit", + "--cov-append", + "--cov-config=.coveragerc", + "--cov-report=", + "--cov-fail-under=0", + os.path.join("tests", "unit"), + *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) + + +def install_systemtest_dependencies(session, *constraints): + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) +def system(session): + """Run the system test suite.""" + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) + system_test_path = os.path.join("tests", "system.py") + system_test_folder_path = os.path.join("tests", "system") + + # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. + if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": + session.skip("RUN_SYSTEM_TESTS is set to false, skipping") + # Install pyopenssl for mTLS testing. + if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": + session.install("pyopenssl") + + system_test_exists = os.path.exists(system_test_path) + system_test_folder_exists = os.path.exists(system_test_folder_path) + # Sanity check: only run tests if found. + if not system_test_exists and not system_test_folder_exists: + session.skip("System tests were not found") + + install_systemtest_dependencies(session, "-c", constraints_path) + + # Run py.test against the system tests. + if system_test_exists: + session.run( + "py.test", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_path, + *session.posargs, + ) + if system_test_folder_exists: + session.run( + "py.test", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_folder_path, + *session.posargs, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def cover(session): + """Run the final coverage report. + + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python="3.10") +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install( + # We need to pin to specific versions of the `sphinxcontrib-*` packages + # which still support sphinx 4.x. + # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 + # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. + "sphinxcontrib-applehelp==1.0.4", + "sphinxcontrib-devhelp==1.0.2", + "sphinxcontrib-htmlhelp==2.0.1", + "sphinxcontrib-qthelp==1.0.3", + "sphinxcontrib-serializinghtml==1.1.5", + "sphinx==4.5.0", + "alabaster", + "recommonmark", + ) + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", "html", # builder + "-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory + # paths to build: + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) + + +@nox.session(python="3.10") +def docfx(session): + """Build the docfx yaml files for this library.""" + + session.install("-e", ".") + session.install( + # We need to pin to specific versions of the `sphinxcontrib-*` packages + # which still support sphinx 4.x. + # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 + # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. + "sphinxcontrib-applehelp==1.0.4", + "sphinxcontrib-devhelp==1.0.2", + "sphinxcontrib-htmlhelp==2.0.1", + "sphinxcontrib-qthelp==1.0.3", + "sphinxcontrib-serializinghtml==1.1.5", + "gcp-sphinx-docfx-yaml", + "alabaster", + "recommonmark", + ) + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-T", # show full traceback on exception + "-N", # no colors + "-D", + ( + "extensions=sphinx.ext.autodoc," + "sphinx.ext.autosummary," + "docfx_yaml.extension," + "sphinx.ext.intersphinx," + "sphinx.ext.coverage," + "sphinx.ext.napoleon," + "sphinx.ext.todo," + "sphinx.ext.viewcode," + "recommonmark" + ), + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb", "cpp"], +) +def prerelease_deps(session, protobuf_implementation): + """ + Run all tests with pre-release versions of dependencies installed + rather than the standard non pre-release versions. + Pre-release versions can be installed using + `pip install --pre `. + """ + + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): + session.skip("cpp implementation is not supported in python 3.11+") + + # Install all dependencies + session.install("-e", ".") + + # Install dependencies for the unit test environment + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES + session.install(*unit_deps_all) + + # Install dependencies for the system test environment + system_deps_all = ( + SYSTEM_TEST_STANDARD_DEPENDENCIES + + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + + SYSTEM_TEST_EXTRAS + ) + session.install(*system_deps_all) + + # Because we test minimum dependency versions on the minimum Python + # version, the first version we test with in the unit tests sessions has a + # constraints file containing all dependencies and extras. + with open( + CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_PYTHON[0]}.txt", + encoding="utf-8", + ) as constraints_file: + constraints_text = constraints_file.read() + + # Ignore leading whitespace and comment lines. + constraints_deps = [ + match.group(1) + for match in re.finditer( + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE + ) + ] + + # Install dependencies specified in `testing/constraints-X.txt`. + session.install(*constraints_deps) + + # Note: If a dependency is added to the `prerel_deps` list, + # the `core_dependencies_from_source` list in the `core_deps_from_source` + # nox session should also be updated. + prerel_deps = [ + "googleapis-common-protos", + "google-api-core", + "google-auth", + "grpc-google-iam-v1", + "grpcio", + "grpcio-status", + "protobuf", + "proto-plus", + ] + + for dep in prerel_deps: + session.install("--pre", "--no-deps", "--ignore-installed", dep) + # TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status`` + # to the dictionary below once this bug is fixed. + # TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add + # `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below + # once this bug is fixed. + package_namespaces = { + "google-api-core": "google.api_core", + "google-auth": "google.auth", + "grpcio": "grpc", + "protobuf": "google.protobuf", + "proto-plus": "proto", + } + + version_namespace = package_namespaces.get(dep) + + print(f"Installed {dep}") + if version_namespace: + session.run( + "python", + "-c", + f"import {version_namespace}; print({version_namespace}.__version__)", + ) + + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +@nox.parametrize( + "protobuf_implementation", + ["python", "upb"], +) +def core_deps_from_source(session, protobuf_implementation): + """Run all tests with core dependencies installed from source + rather than pulling the dependencies from PyPI. + """ + + # Install all dependencies + session.install("-e", ".") + + # Install dependencies for the unit test environment + unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES + session.install(*unit_deps_all) + + # Install dependencies for the system test environment + system_deps_all = ( + SYSTEM_TEST_STANDARD_DEPENDENCIES + + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + + SYSTEM_TEST_EXTRAS + ) + session.install(*system_deps_all) + + # Because we test minimum dependency versions on the minimum Python + # version, the first version we test with in the unit tests sessions has a + # constraints file containing all dependencies and extras. + with open( + CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_PYTHON[0]}.txt", + encoding="utf-8", + ) as constraints_file: + constraints_text = constraints_file.read() + + # Ignore leading whitespace and comment lines. + constraints_deps = [ + match.group(1) + for match in re.finditer( + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE + ) + ] + + # Install dependencies specified in `testing/constraints-X.txt`. + session.install(*constraints_deps) + + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and + # `grpcio-status` should be added to the list below so that they are installed from source, + # rather than PyPI. + # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be + # added to the list below so that it is installed from source, rather than PyPI + # Note: If a dependency is added to the `core_dependencies_from_source` list, + # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated. + core_dependencies_from_source = [ + "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos", + "google-api-core @ git+https://github.com/googleapis/python-api-core.git", + "google-auth @ git+https://github.com/googleapis/google-auth-library-python.git", + "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1", + "proto-plus @ git+https://github.com/googleapis/proto-plus-python.git", + ] + + for dep in core_dependencies_from_source: + session.install(dep, "--no-deps", "--ignore-installed") + print(f"Installed {dep}") + + session.run( + "py.test", + "tests/unit", + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json new file mode 100644 index 000000000000..2e9dbfeedb7e --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json @@ -0,0 +1,4957 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.video.stitcher.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-video-stitcher", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "cdn_key", + "type": "google.cloud.video.stitcher_v1.types.CdnKey" + }, + { + "name": "cdn_key_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_cdn_key" + }, + "description": "Sample for CreateCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "cdn_key", + "type": "google.cloud.video.stitcher_v1.types.CdnKey" + }, + { + "name": "cdn_key_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_cdn_key" + }, + "description": "Sample for CreateCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "live_config", + "type": "google.cloud.video.stitcher_v1.types.LiveConfig" + }, + { + "name": "live_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_live_config" + }, + "description": "Sample for CreateLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_async", + "segments": [ + { + "end": 61, + "start": 27, + "type": "FULL" + }, + { + "end": 61, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 58, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 62, + "start": 59, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "live_config", + "type": "google.cloud.video.stitcher_v1.types.LiveConfig" + }, + { + "name": "live_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_live_config" + }, + "description": "Sample for CreateLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_sync", + "segments": [ + { + "end": 61, + "start": 27, + "type": "FULL" + }, + { + "end": 61, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 58, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 62, + "start": 59, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_live_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateLiveSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "live_session", + "type": "google.cloud.video.stitcher_v1.types.LiveSession" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", + "shortName": "create_live_session" + }, + "description": "Sample for CreateLiveSession", + "file": "videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateLiveSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "live_session", + "type": "google.cloud.video.stitcher_v1.types.LiveSession" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", + "shortName": "create_live_session" + }, + "description": "Sample for CreateLiveSession", + "file": "videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateSlateRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "slate", + "type": "google.cloud.video.stitcher_v1.types.Slate" + }, + { + "name": "slate_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_slate" + }, + "description": "Sample for CreateSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_create_slate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateSlate_async", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_slate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateSlateRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "slate", + "type": "google.cloud.video.stitcher_v1.types.Slate" + }, + { + "name": "slate_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_slate" + }, + "description": "Sample for CreateSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateSlate_sync", + "segments": [ + { + "end": 56, + "start": 27, + "type": "FULL" + }, + { + "end": 56, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 46, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 53, + "start": 47, + "type": "REQUEST_EXECUTION" + }, + { + "end": 57, + "start": 54, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateVodConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "vod_config", + "type": "google.cloud.video.stitcher_v1.types.VodConfig" + }, + { + "name": "vod_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_vod_config" + }, + "description": "Sample for CreateVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_async", + "segments": [ + { + "end": 61, + "start": 27, + "type": "FULL" + }, + { + "end": 61, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 58, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 62, + "start": 59, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateVodConfigRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "vod_config", + "type": "google.cloud.video.stitcher_v1.types.VodConfig" + }, + { + "name": "vod_config_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_vod_config" + }, + "description": "Sample for CreateVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_sync", + "segments": [ + { + "end": 61, + "start": 27, + "type": "FULL" + }, + { + "end": 61, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 51, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 58, + "start": 52, + "type": "REQUEST_EXECUTION" + }, + { + "end": 62, + "start": 59, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_vod_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateVodSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateVodSessionRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "vod_session", + "type": "google.cloud.video.stitcher_v1.types.VodSession" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodSession", + "shortName": "create_vod_session" + }, + "description": "Sample for CreateVodSession", + "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodSession_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "CreateVodSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.CreateVodSessionRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "vod_session", + "type": "google.cloud.video.stitcher_v1.types.VodSession" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodSession", + "shortName": "create_vod_session" + }, + "description": "Sample for CreateVodSession", + "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodSession_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_cdn_key" + }, + "description": "Sample for DeleteCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_cdn_key" + }, + "description": "Sample for DeleteCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_live_config" + }, + "description": "Sample for DeleteLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_live_config" + }, + "description": "Sample for DeleteLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteSlateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_slate" + }, + "description": "Sample for DeleteSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteSlate_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteSlateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_slate" + }, + "description": "Sample for DeleteSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteSlate_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_vod_config" + }, + "description": "Sample for DeleteVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "DeleteVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_vod_config" + }, + "description": "Sample for DeleteVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetCdnKeyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", + "shortName": "get_cdn_key" + }, + "description": "Sample for GetCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetCdnKey_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetCdnKeyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", + "shortName": "get_cdn_key" + }, + "description": "Sample for GetCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetCdnKey_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_live_ad_tag_detail", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveAdTagDetail", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetLiveAdTagDetail" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", + "shortName": "get_live_ad_tag_detail" + }, + "description": "Sample for GetLiveAdTagDetail", + "file": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_ad_tag_detail", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveAdTagDetail", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetLiveAdTagDetail" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", + "shortName": "get_live_ad_tag_detail" + }, + "description": "Sample for GetLiveAdTagDetail", + "file": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetLiveConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", + "shortName": "get_live_config" + }, + "description": "Sample for GetLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetLiveConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", + "shortName": "get_live_config" + }, + "description": "Sample for GetLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_live_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetLiveSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetLiveSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", + "shortName": "get_live_session" + }, + "description": "Sample for GetLiveSession", + "file": "videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveSession_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetLiveSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetLiveSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", + "shortName": "get_live_session" + }, + "description": "Sample for GetLiveSession", + "file": "videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveSession_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetSlateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.Slate", + "shortName": "get_slate" + }, + "description": "Sample for GetSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_get_slate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetSlate_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_slate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetSlateRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.Slate", + "shortName": "get_slate" + }, + "description": "Sample for GetSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetSlate_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_ad_tag_detail", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodAdTagDetail", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodAdTagDetail" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", + "shortName": "get_vod_ad_tag_detail" + }, + "description": "Sample for GetVodAdTagDetail", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_ad_tag_detail", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodAdTagDetail", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodAdTagDetail" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", + "shortName": "get_vod_ad_tag_detail" + }, + "description": "Sample for GetVodAdTagDetail", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", + "shortName": "get_vod_config" + }, + "description": "Sample for GetVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodConfig_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodConfigRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", + "shortName": "get_vod_config" + }, + "description": "Sample for GetVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodConfig_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodSession", + "shortName": "get_vod_session" + }, + "description": "Sample for GetVodSession", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodSession_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_session", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodSession", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodSession" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodSessionRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodSession", + "shortName": "get_vod_session" + }, + "description": "Sample for GetVodSession", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodSession_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_stitch_detail", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodStitchDetail", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodStitchDetail" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", + "shortName": "get_vod_stitch_detail" + }, + "description": "Sample for GetVodStitchDetail", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_stitch_detail", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodStitchDetail", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "GetVodStitchDetail" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", + "shortName": "get_vod_stitch_detail" + }, + "description": "Sample for GetVodStitchDetail", + "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_cdn_keys", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListCdnKeys", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListCdnKeys" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListCdnKeysRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager", + "shortName": "list_cdn_keys" + }, + "description": "Sample for ListCdnKeys", + "file": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_cdn_keys", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListCdnKeys", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListCdnKeys" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListCdnKeysRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager", + "shortName": "list_cdn_keys" + }, + "description": "Sample for ListCdnKeys", + "file": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_live_ad_tag_details", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveAdTagDetails", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListLiveAdTagDetails" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager", + "shortName": "list_live_ad_tag_details" + }, + "description": "Sample for ListLiveAdTagDetails", + "file": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_ad_tag_details", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveAdTagDetails", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListLiveAdTagDetails" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager", + "shortName": "list_live_ad_tag_details" + }, + "description": "Sample for ListLiveAdTagDetails", + "file": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_live_configs", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveConfigs", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListLiveConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager", + "shortName": "list_live_configs" + }, + "description": "Sample for ListLiveConfigs", + "file": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_configs", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveConfigs", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListLiveConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager", + "shortName": "list_live_configs" + }, + "description": "Sample for ListLiveConfigs", + "file": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_slates", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListSlates", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListSlates" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListSlatesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager", + "shortName": "list_slates" + }, + "description": "Sample for ListSlates", + "file": "videostitcher_v1_generated_video_stitcher_service_list_slates_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListSlates_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_slates_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_slates", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListSlates", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListSlates" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListSlatesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager", + "shortName": "list_slates" + }, + "description": "Sample for ListSlates", + "file": "videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListSlates_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_vod_ad_tag_details", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodAdTagDetails", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListVodAdTagDetails" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager", + "shortName": "list_vod_ad_tag_details" + }, + "description": "Sample for ListVodAdTagDetails", + "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_ad_tag_details", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodAdTagDetails", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListVodAdTagDetails" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager", + "shortName": "list_vod_ad_tag_details" + }, + "description": "Sample for ListVodAdTagDetails", + "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_vod_configs", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodConfigs", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListVodConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListVodConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager", + "shortName": "list_vod_configs" + }, + "description": "Sample for ListVodConfigs", + "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_configs", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodConfigs", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListVodConfigs" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListVodConfigsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager", + "shortName": "list_vod_configs" + }, + "description": "Sample for ListVodConfigs", + "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_vod_stitch_details", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodStitchDetails", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListVodStitchDetails" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager", + "shortName": "list_vod_stitch_details" + }, + "description": "Sample for ListVodStitchDetails", + "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_stitch_details", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodStitchDetails", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "ListVodStitchDetails" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager", + "shortName": "list_vod_stitch_details" + }, + "description": "Sample for ListVodStitchDetails", + "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest" + }, + { + "name": "cdn_key", + "type": "google.cloud.video.stitcher_v1.types.CdnKey" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_cdn_key" + }, + "description": "Sample for UpdateCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_cdn_key", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateCdnKey", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateCdnKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest" + }, + { + "name": "cdn_key", + "type": "google.cloud.video.stitcher_v1.types.CdnKey" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_cdn_key" + }, + "description": "Sample for UpdateCdnKey", + "file": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest" + }, + { + "name": "live_config", + "type": "google.cloud.video.stitcher_v1.types.LiveConfig" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_live_config" + }, + "description": "Sample for UpdateLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_live_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateLiveConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateLiveConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest" + }, + { + "name": "live_config", + "type": "google.cloud.video.stitcher_v1.types.LiveConfig" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_live_config" + }, + "description": "Sample for UpdateLiveConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateSlateRequest" + }, + { + "name": "slate", + "type": "google.cloud.video.stitcher_v1.types.Slate" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_slate" + }, + "description": "Sample for UpdateSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_update_slate_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateSlate_async", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_slate_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_slate", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateSlate", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateSlate" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateSlateRequest" + }, + { + "name": "slate", + "type": "google.cloud.video.stitcher_v1.types.Slate" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_slate" + }, + "description": "Sample for UpdateSlate", + "file": "videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateSlate_sync", + "segments": [ + { + "end": 54, + "start": 27, + "type": "FULL" + }, + { + "end": 54, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 51, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 55, + "start": 52, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", + "shortName": "VideoStitcherServiceAsyncClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest" + }, + { + "name": "vod_config", + "type": "google.cloud.video.stitcher_v1.types.VodConfig" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_vod_config" + }, + "description": "Sample for UpdateVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_async", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", + "shortName": "VideoStitcherServiceClient" + }, + "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_vod_config", + "method": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateVodConfig", + "service": { + "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "shortName": "VideoStitcherService" + }, + "shortName": "UpdateVodConfig" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest" + }, + { + "name": "vod_config", + "type": "google.cloud.video.stitcher_v1.types.VodConfig" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, Union[str, bytes]]]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_vod_config" + }, + "description": "Sample for UpdateVodConfig", + "file": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_sync", + "segments": [ + { + "end": 59, + "start": 27, + "type": "FULL" + }, + { + "end": 59, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 56, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 60, + "start": 57, + "type": "RESPONSE_HANDLING" + } + ], + "title": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py" + } + ] +} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py new file mode 100644 index 000000000000..c51d8ee2d3fd --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_create_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateCdnKeyRequest( + parent="parent_value", + cdn_key_id="cdn_key_id_value", + ) + + # Make the request + operation = client.create_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py new file mode 100644 index 000000000000..25a8bb90f12b --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_create_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateCdnKeyRequest( + parent="parent_value", + cdn_key_id="cdn_key_id_value", + ) + + # Make the request + operation = client.create_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py new file mode 100644 index 000000000000..5306106cda8e --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_create_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.CreateLiveConfigRequest( + parent="parent_value", + live_config_id="live_config_id_value", + live_config=live_config, + ) + + # Make the request + operation = client.create_live_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py new file mode 100644 index 000000000000..2f32c4b0ba10 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_create_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.CreateLiveConfigRequest( + parent="parent_value", + live_config_id="live_config_id_value", + live_config=live_config, + ) + + # Make the request + operation = client.create_live_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py new file mode 100644 index 000000000000..d626bf3c595d --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateLiveSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_create_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + live_session = stitcher_v1.LiveSession() + live_session.live_config = "live_config_value" + + request = stitcher_v1.CreateLiveSessionRequest( + parent="parent_value", + live_session=live_session, + ) + + # Make the request + response = await client.create_live_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py new file mode 100644 index 000000000000..98c56f488ac1 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateLiveSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_create_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + live_session = stitcher_v1.LiveSession() + live_session.live_config = "live_config_value" + + request = stitcher_v1.CreateLiveSessionRequest( + parent="parent_value", + live_session=live_session, + ) + + # Make the request + response = client.create_live_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py new file mode 100644 index 000000000000..2d23f2bc7524 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateSlate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_create_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateSlateRequest( + parent="parent_value", + slate_id="slate_id_value", + ) + + # Make the request + operation = client.create_slate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py new file mode 100644 index 000000000000..257a9c6fd509 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateSlate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_create_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.CreateSlateRequest( + parent="parent_value", + slate_id="slate_id_value", + ) + + # Make the request + operation = client.create_slate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py new file mode 100644 index 000000000000..8517f766b866 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_create_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.CreateVodConfigRequest( + parent="parent_value", + vod_config_id="vod_config_id_value", + vod_config=vod_config, + ) + + # Make the request + operation = client.create_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py new file mode 100644 index 000000000000..641d461c66e7 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_create_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.CreateVodConfigRequest( + parent="parent_value", + vod_config_id="vod_config_id_value", + vod_config=vod_config, + ) + + # Make the request + operation = client.create_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py new file mode 100644 index 000000000000..9d541de682d4 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVodSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateVodSession_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_create_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + vod_session = stitcher_v1.VodSession() + vod_session.ad_tracking = "SERVER" + + request = stitcher_v1.CreateVodSessionRequest( + parent="parent_value", + vod_session=vod_session, + ) + + # Make the request + response = await client.create_vod_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateVodSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py new file mode 100644 index 000000000000..0cdffdcdc95f --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateVodSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_CreateVodSession_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_create_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + vod_session = stitcher_v1.VodSession() + vod_session.ad_tracking = "SERVER" + + request = stitcher_v1.CreateVodSessionRequest( + parent="parent_value", + vod_session=vod_session, + ) + + # Make the request + response = client.create_vod_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_CreateVodSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py new file mode 100644 index 000000000000..c8e98285da74 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_delete_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteCdnKeyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py new file mode 100644 index 000000000000..b63886851fc0 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_delete_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteCdnKeyRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py new file mode 100644 index 000000000000..2c64239b7955 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_delete_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteLiveConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_live_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py new file mode 100644 index 000000000000..d2383dfe00a5 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_delete_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteLiveConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_live_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py new file mode 100644 index 000000000000..132639b48676 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteSlate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_delete_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteSlateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_slate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py new file mode 100644 index 000000000000..66260563d841 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteSlate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_delete_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteSlateRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_slate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py new file mode 100644 index 000000000000..a71922a5c802 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_delete_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteVodConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py new file mode 100644 index 000000000000..6f7af4c8b244 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_delete_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.DeleteVodConfigRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py new file mode 100644 index 000000000000..9248cceecf70 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetCdnKey_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetCdnKeyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_cdn_key(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py new file mode 100644 index 000000000000..c6a684399152 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetCdnKey_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetCdnKeyRequest( + name="name_value", + ) + + # Make the request + response = client.get_cdn_key(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py new file mode 100644 index 000000000000..0c7193fc2e6f --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetLiveAdTagDetail +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_live_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = await client.get_live_ad_tag_detail(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py new file mode 100644 index 000000000000..2d3c3758d4fd --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetLiveAdTagDetail +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_live_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = client.get_live_ad_tag_detail(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py new file mode 100644 index 000000000000..0f7d8640947e --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_live_config(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py new file mode 100644 index 000000000000..9fe672785910 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_live_config(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py new file mode 100644 index 000000000000..05f617f0d762 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetLiveSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetLiveSession_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveSessionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_live_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetLiveSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py new file mode 100644 index 000000000000..e00f50782c38 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetLiveSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetLiveSession_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_live_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetLiveSessionRequest( + name="name_value", + ) + + # Make the request + response = client.get_live_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetLiveSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py new file mode 100644 index 000000000000..ca869f6067cf --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetSlate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetSlateRequest( + name="name_value", + ) + + # Make the request + response = await client.get_slate(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py new file mode 100644 index 000000000000..47cc4206917e --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetSlate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetSlateRequest( + name="name_value", + ) + + # Make the request + response = client.get_slate(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py new file mode 100644 index 000000000000..24bc14bc5aa6 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodAdTagDetail +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_vod_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_ad_tag_detail(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py new file mode 100644 index 000000000000..c25aceaf1c3e --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodAdTagDetail +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_vod_ad_tag_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodAdTagDetailRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_ad_tag_detail(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py new file mode 100644 index 000000000000..e652f20e8433 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_config(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py new file mode 100644 index 000000000000..080af38ee645 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_config(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py new file mode 100644 index 000000000000..b2f6c6abe203 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodSession_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodSessionRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py new file mode 100644 index 000000000000..9cfee64e3bb3 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodSession +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodSession_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_vod_session(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodSessionRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_session(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py new file mode 100644 index 000000000000..df8dc4fb1e71 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodStitchDetail +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_get_vod_stitch_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodStitchDetailRequest( + name="name_value", + ) + + # Make the request + response = await client.get_vod_stitch_detail(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py new file mode 100644 index 000000000000..09acbf2e6df5 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetVodStitchDetail +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_get_vod_stitch_detail(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.GetVodStitchDetailRequest( + name="name_value", + ) + + # Make the request + response = client.get_vod_stitch_detail(request=request) + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py new file mode 100644 index 000000000000..91a4a5cc28d6 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCdnKeys +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_list_cdn_keys(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListCdnKeysRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_cdn_keys(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py new file mode 100644 index 000000000000..804e5fb686da --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListCdnKeys +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_list_cdn_keys(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListCdnKeysRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_cdn_keys(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py new file mode 100644 index 000000000000..4665b8691317 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListLiveAdTagDetails +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_list_live_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_ad_tag_details(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py new file mode 100644 index 000000000000..d5d16ca7d706 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListLiveAdTagDetails +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_list_live_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_ad_tag_details(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py new file mode 100644 index 000000000000..2b828784566f --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListLiveConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_list_live_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py new file mode 100644 index 000000000000..5a44cf5cde09 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListLiveConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_list_live_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListLiveConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_live_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py new file mode 100644 index 000000000000..ce62661438cd --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSlates +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListSlates_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_list_slates(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListSlatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_slates(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListSlates_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py new file mode 100644 index 000000000000..7ce16be126e3 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListSlates +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListSlates_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_list_slates(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListSlatesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_slates(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListSlates_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py new file mode 100644 index 000000000000..7c4b1a402dcd --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVodAdTagDetails +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_list_vod_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_ad_tag_details(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py new file mode 100644 index 000000000000..c3cf51689ca4 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVodAdTagDetails +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_list_vod_ad_tag_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodAdTagDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_ad_tag_details(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py new file mode 100644 index 000000000000..67e53bbfa8de --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVodConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_list_vod_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_configs(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py new file mode 100644 index 000000000000..7f2f0ad278a7 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVodConfigs +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_list_vod_configs(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodConfigsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_configs(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py new file mode 100644 index 000000000000..e7cd106a8e74 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVodStitchDetails +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_list_vod_stitch_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodStitchDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_stitch_details(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py new file mode 100644 index 000000000000..647f195a0317 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListVodStitchDetails +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_list_vod_stitch_details(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.ListVodStitchDetailsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_vod_stitch_details(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py new file mode 100644 index 000000000000..60a63a672291 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_update_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateCdnKeyRequest( + ) + + # Make the request + operation = client.update_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py new file mode 100644 index 000000000000..ce8e5b3d2bc8 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateCdnKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_update_cdn_key(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateCdnKeyRequest( + ) + + # Make the request + operation = client.update_cdn_key(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py new file mode 100644 index 000000000000..620c353086ea --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_update_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.UpdateLiveConfigRequest( + live_config=live_config, + ) + + # Make the request + operation = client.update_live_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py new file mode 100644 index 000000000000..6a8ca8872608 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateLiveConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_update_live_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + live_config = stitcher_v1.LiveConfig() + live_config.source_uri = "source_uri_value" + live_config.ad_tracking = "SERVER" + + request = stitcher_v1.UpdateLiveConfigRequest( + live_config=live_config, + ) + + # Make the request + operation = client.update_live_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py new file mode 100644 index 000000000000..aef61f0b0086 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateSlate_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_update_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateSlateRequest( + ) + + # Make the request + operation = client.update_slate(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py new file mode 100644 index 000000000000..cbb7445e4027 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateSlate +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateSlate_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_update_slate(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + request = stitcher_v1.UpdateSlateRequest( + ) + + # Make the request + operation = client.update_slate(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py new file mode 100644 index 000000000000..35362d3763a2 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_async] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +async def sample_update_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceAsyncClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.UpdateVodConfigRequest( + vod_config=vod_config, + ) + + # Make the request + operation = client.update_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = (await operation).result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py new file mode 100644 index 000000000000..62eca54d3944 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateVodConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-video-stitcher + + +# [START videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_sync] +# This snippet has been automatically generated and should be regarded as a +# code template only. +# It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in: +# https://googleapis.dev/python/google-api-core/latest/client_options.html +from google.cloud.video import stitcher_v1 + + +def sample_update_vod_config(): + # Create a client + client = stitcher_v1.VideoStitcherServiceClient() + + # Initialize request argument(s) + vod_config = stitcher_v1.VodConfig() + vod_config.source_uri = "source_uri_value" + vod_config.ad_tag_uri = "ad_tag_uri_value" + + request = stitcher_v1.UpdateVodConfigRequest( + vod_config=vod_config, + ) + + # Make the request + operation = client.update_vod_config(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py b/owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py new file mode 100644 index 000000000000..0f4ecc0cfa74 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py @@ -0,0 +1,205 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class stitcherCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_cdn_key': ('parent', 'cdn_key', 'cdn_key_id', ), + 'create_live_config': ('parent', 'live_config_id', 'live_config', 'request_id', ), + 'create_live_session': ('parent', 'live_session', ), + 'create_slate': ('parent', 'slate_id', 'slate', 'request_id', ), + 'create_vod_config': ('parent', 'vod_config_id', 'vod_config', 'request_id', ), + 'create_vod_session': ('parent', 'vod_session', ), + 'delete_cdn_key': ('name', ), + 'delete_live_config': ('name', ), + 'delete_slate': ('name', ), + 'delete_vod_config': ('name', ), + 'get_cdn_key': ('name', ), + 'get_live_ad_tag_detail': ('name', ), + 'get_live_config': ('name', ), + 'get_live_session': ('name', ), + 'get_slate': ('name', ), + 'get_vod_ad_tag_detail': ('name', ), + 'get_vod_config': ('name', ), + 'get_vod_session': ('name', ), + 'get_vod_stitch_detail': ('name', ), + 'list_cdn_keys': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_live_ad_tag_details': ('parent', 'page_size', 'page_token', ), + 'list_live_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_slates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_vod_ad_tag_details': ('parent', 'page_size', 'page_token', ), + 'list_vod_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_vod_stitch_details': ('parent', 'page_size', 'page_token', ), + 'update_cdn_key': ('cdn_key', 'update_mask', ), + 'update_live_config': ('live_config', 'update_mask', ), + 'update_slate': ('slate', 'update_mask', ), + 'update_vod_config': ('vod_config', 'update_mask', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=stitcherCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the stitcher client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/setup.py b/owl-bot-staging/google-cloud-video-stitcher/v1/setup.py new file mode 100644 index 000000000000..21e868ffe679 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/setup.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import io +import os +import re + +import setuptools # type: ignore + +package_root = os.path.abspath(os.path.dirname(__file__)) + +name = 'google-cloud-video-stitcher' + + +description = "Google Cloud Video Stitcher API client library" + +version = None + +with open(os.path.join(package_root, 'google/cloud/video/stitcher/gapic_version.py')) as fp: + version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read()) + assert (len(version_candidates) == 1) + version = version_candidates[0] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + +dependencies = [ + "google-api-core[grpc] >= 1.34.1, <3.0.0,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + # Exclude incompatible versions of `google-auth` + # See https://github.com/googleapis/google-cloud-python/issues/12364 + "google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0", + "proto-plus >= 1.22.3, <2.0.0", + "proto-plus >= 1.25.0, <2.0.0; python_version >= '3.13'", + "protobuf>=3.20.2,<7.0.0,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", +] +extras = { +} +url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-video-stitcher" + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, "README.rst") +with io.open(readme_filename, encoding="utf-8") as readme_file: + readme = readme_file.read() + +packages = [ + package + for package in setuptools.find_namespace_packages() + if package.startswith("google") +] + +setuptools.setup( + name=name, + version=version, + description=description, + long_description=readme, + author="Google LLC", + author_email="googleapis-packages@google.com", + license="Apache 2.0", + url=url, + classifiers=[ + release_status, + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Operating System :: OS Independent", + "Topic :: Internet", + ], + platforms="Posix; MacOS X; Windows", + packages=packages, + python_requires=">=3.7", + install_requires=dependencies, + extras_require=extras, + include_package_data=True, + zip_safe=False, +) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt new file mode 100644 index 000000000000..c20a77817caa --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt @@ -0,0 +1,11 @@ +# We use the constraints file for the latest Python version +# (currently this file) to check that the latest +# major versions of dependencies are supported in setup.py. +# List all library dependencies and extras in this file. +# Require the latest major version be installed for each dependency. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0", +# Then this file should have google-cloud-foo>=1 +google-api-core>=2 +google-auth>=2 +proto-plus>=1 +protobuf>=6 diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt new file mode 100644 index 000000000000..a77f12bc13e4 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt @@ -0,0 +1,10 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.34.1 +google-auth==2.14.1 +proto-plus==1.22.3 +protobuf==3.20.2 diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt new file mode 100644 index 000000000000..ed7f9aed2559 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py new file mode 100644 index 000000000000..191773d5572d --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py new file mode 100644 index 000000000000..9a75ef87b6b1 --- /dev/null +++ b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py @@ -0,0 +1,25166 @@ +# -*- coding: utf-8 -*- +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock + +import grpc +from grpc.experimental import aio +from collections.abc import Iterable, AsyncIterable +from google.protobuf import json_format +import json +import math +import pytest +from google.api_core import api_core_version +from proto.marshal.rules.dates import DurationRule, TimestampRule +from proto.marshal.rules import wrappers +from requests import Response +from requests import Request, PreparedRequest +from requests.sessions import Session +from google.protobuf import json_format + +try: + from google.auth.aio import credentials as ga_credentials_async + HAS_GOOGLE_AUTH_AIO = True +except ImportError: # pragma: NO COVER + HAS_GOOGLE_AUTH_AIO = False + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import future +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import operation +from google.api_core import operation_async # type: ignore +from google.api_core import operations_v1 +from google.api_core import path_template +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.video.stitcher_v1.services.video_stitcher_service import VideoStitcherServiceAsyncClient +from google.cloud.video.stitcher_v1.services.video_stitcher_service import VideoStitcherServiceClient +from google.cloud.video.stitcher_v1.services.video_stitcher_service import pagers +from google.cloud.video.stitcher_v1.services.video_stitcher_service import transports +from google.cloud.video.stitcher_v1.types import ad_tag_details +from google.cloud.video.stitcher_v1.types import cdn_keys +from google.cloud.video.stitcher_v1.types import companions +from google.cloud.video.stitcher_v1.types import events +from google.cloud.video.stitcher_v1.types import fetch_options +from google.cloud.video.stitcher_v1.types import live_configs +from google.cloud.video.stitcher_v1.types import sessions +from google.cloud.video.stitcher_v1.types import slates +from google.cloud.video.stitcher_v1.types import stitch_details +from google.cloud.video.stitcher_v1.types import video_stitcher_service +from google.cloud.video.stitcher_v1.types import vod_configs +from google.longrunning import operations_pb2 # type: ignore +from google.oauth2 import service_account +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +import google.auth + + + +CRED_INFO_JSON = { + "credential_source": "/path/to/file", + "credential_type": "service account credentials", + "principal": "service-account@example.com", +} +CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) + + +async def mock_async_gen(data, chunk_size=1): + for i in range(0, len(data)): # pragma: NO COVER + chunk = data[i : i + chunk_size] + yield chunk.encode("utf-8") + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + +# TODO: use async auth anon credentials by default once the minimum version of google-auth is upgraded. +# See related issue: https://github.com/googleapis/gapic-generator-python/issues/2107. +def async_anonymous_credentials(): + if HAS_GOOGLE_AUTH_AIO: + return ga_credentials_async.AnonymousCredentials() + return ga_credentials.AnonymousCredentials() + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + +# If default endpoint template is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint template so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint_template(client): + return "test.{UNIVERSE_DOMAIN}" if ("localhost" in client._DEFAULT_ENDPOINT_TEMPLATE) else client._DEFAULT_ENDPOINT_TEMPLATE + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert VideoStitcherServiceClient._get_default_mtls_endpoint(None) is None + assert VideoStitcherServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert VideoStitcherServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert VideoStitcherServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert VideoStitcherServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert VideoStitcherServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + +def test__read_environment_variables(): + assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + assert VideoStitcherServiceClient._read_environment_variables() == (True, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError) as excinfo: + VideoStitcherServiceClient._read_environment_variables() + assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + assert VideoStitcherServiceClient._read_environment_variables() == (False, "never", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + assert VideoStitcherServiceClient._read_environment_variables() == (False, "always", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): + assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", None) + + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError) as excinfo: + VideoStitcherServiceClient._read_environment_variables() + assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + + with mock.patch.dict(os.environ, {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": "foo.com"}): + assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", "foo.com") + +def test__get_client_cert_source(): + mock_provided_cert_source = mock.Mock() + mock_default_cert_source = mock.Mock() + + assert VideoStitcherServiceClient._get_client_cert_source(None, False) is None + assert VideoStitcherServiceClient._get_client_cert_source(mock_provided_cert_source, False) is None + assert VideoStitcherServiceClient._get_client_cert_source(mock_provided_cert_source, True) == mock_provided_cert_source + + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_default_cert_source): + assert VideoStitcherServiceClient._get_client_cert_source(None, True) is mock_default_cert_source + assert VideoStitcherServiceClient._get_client_cert_source(mock_provided_cert_source, "true") is mock_provided_cert_source + +@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) +@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) +def test__get_api_endpoint(): + api_override = "foo.com" + mock_client_cert_source = mock.Mock() + default_universe = VideoStitcherServiceClient._DEFAULT_UNIVERSE + default_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) + mock_universe = "bar.com" + mock_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) + + assert VideoStitcherServiceClient._get_api_endpoint(api_override, mock_client_cert_source, default_universe, "always") == api_override + assert VideoStitcherServiceClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "auto") == VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT + assert VideoStitcherServiceClient._get_api_endpoint(None, None, default_universe, "auto") == default_endpoint + assert VideoStitcherServiceClient._get_api_endpoint(None, None, default_universe, "always") == VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT + assert VideoStitcherServiceClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "always") == VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT + assert VideoStitcherServiceClient._get_api_endpoint(None, None, mock_universe, "never") == mock_endpoint + assert VideoStitcherServiceClient._get_api_endpoint(None, None, default_universe, "never") == default_endpoint + + with pytest.raises(MutualTLSChannelError) as excinfo: + VideoStitcherServiceClient._get_api_endpoint(None, mock_client_cert_source, mock_universe, "auto") + assert str(excinfo.value) == "mTLS is not supported in any universe other than googleapis.com." + + +def test__get_universe_domain(): + client_universe_domain = "foo.com" + universe_domain_env = "bar.com" + + assert VideoStitcherServiceClient._get_universe_domain(client_universe_domain, universe_domain_env) == client_universe_domain + assert VideoStitcherServiceClient._get_universe_domain(None, universe_domain_env) == universe_domain_env + assert VideoStitcherServiceClient._get_universe_domain(None, None) == VideoStitcherServiceClient._DEFAULT_UNIVERSE + + with pytest.raises(ValueError) as excinfo: + VideoStitcherServiceClient._get_universe_domain("", None) + assert str(excinfo.value) == "Universe Domain cannot be an empty string." + +@pytest.mark.parametrize("error_code,cred_info_json,show_cred_info", [ + (401, CRED_INFO_JSON, True), + (403, CRED_INFO_JSON, True), + (404, CRED_INFO_JSON, True), + (500, CRED_INFO_JSON, False), + (401, None, False), + (403, None, False), + (404, None, False), + (500, None, False) +]) +def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info): + cred = mock.Mock(["get_cred_info"]) + cred.get_cred_info = mock.Mock(return_value=cred_info_json) + client = VideoStitcherServiceClient(credentials=cred) + client._transport._credentials = cred + + error = core_exceptions.GoogleAPICallError("message", details=["foo"]) + error.code = error_code + + client._add_cred_info_for_auth_errors(error) + if show_cred_info: + assert error.details == ["foo", CRED_INFO_STRING] + else: + assert error.details == ["foo"] + +@pytest.mark.parametrize("error_code", [401,403,404,500]) +def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code): + cred = mock.Mock([]) + assert not hasattr(cred, "get_cred_info") + client = VideoStitcherServiceClient(credentials=cred) + client._transport._credentials = cred + + error = core_exceptions.GoogleAPICallError("message", details=[]) + error.code = error_code + + client._add_cred_info_for_auth_errors(error) + assert error.details == [] + +@pytest.mark.parametrize("client_class,transport_name", [ + (VideoStitcherServiceClient, "grpc"), + (VideoStitcherServiceAsyncClient, "grpc_asyncio"), + (VideoStitcherServiceClient, "rest"), +]) +def test_video_stitcher_service_client_from_service_account_info(client_class, transport_name): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info, transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'videostitcher.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://videostitcher.googleapis.com' + ) + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.VideoStitcherServiceGrpcTransport, "grpc"), + (transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.VideoStitcherServiceRestTransport, "rest"), +]) +def test_video_stitcher_service_client_service_account_always_use_jwt(transport_class, transport_name): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize("client_class,transport_name", [ + (VideoStitcherServiceClient, "grpc"), + (VideoStitcherServiceAsyncClient, "grpc_asyncio"), + (VideoStitcherServiceClient, "rest"), +]) +def test_video_stitcher_service_client_from_service_account_file(client_class, transport_name): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'videostitcher.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://videostitcher.googleapis.com' + ) + + +def test_video_stitcher_service_client_get_transport_class(): + transport = VideoStitcherServiceClient.get_transport_class() + available_transports = [ + transports.VideoStitcherServiceGrpcTransport, + transports.VideoStitcherServiceRestTransport, + ] + assert transport in available_transports + + transport = VideoStitcherServiceClient.get_transport_class("grpc") + assert transport == transports.VideoStitcherServiceGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc"), + (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio"), + (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest"), +]) +@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) +@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) +def test_video_stitcher_service_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(VideoStitcherServiceClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(VideoStitcherServiceClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError) as excinfo: + client = client_class(transport=transport_name) + assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError) as excinfo: + client = client_class(transport=transport_name) + assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions(api_audience="https://language.googleapis.com") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", "true"), + (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", "false"), + (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), + (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest", "true"), + (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest", "false"), +]) +@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) +@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_video_stitcher_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + VideoStitcherServiceClient, VideoStitcherServiceAsyncClient +]) +@mock.patch.object(VideoStitcherServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VideoStitcherServiceClient)) +@mock.patch.object(VideoStitcherServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VideoStitcherServiceAsyncClient)) +def test_video_stitcher_service_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError) as excinfo: + client_class.get_mtls_endpoint_and_cert_source() + + assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError) as excinfo: + client_class.get_mtls_endpoint_and_cert_source() + + assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + +@pytest.mark.parametrize("client_class", [ + VideoStitcherServiceClient, VideoStitcherServiceAsyncClient +]) +@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) +@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) +def test_video_stitcher_service_client_client_api_endpoint(client_class): + mock_client_cert_source = client_cert_source_callback + api_override = "foo.com" + default_universe = VideoStitcherServiceClient._DEFAULT_UNIVERSE + default_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) + mock_universe = "bar.com" + mock_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) + + # If ClientOptions.api_endpoint is set and GOOGLE_API_USE_CLIENT_CERTIFICATE="true", + # use ClientOptions.api_endpoint as the api endpoint regardless. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"): + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=api_override) + client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) + assert client.api_endpoint == api_override + + # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="never", + # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + client = client_class(credentials=ga_credentials.AnonymousCredentials()) + assert client.api_endpoint == default_endpoint + + # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="always", + # use the DEFAULT_MTLS_ENDPOINT as the api endpoint. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + client = client_class(credentials=ga_credentials.AnonymousCredentials()) + assert client.api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + + # If ClientOptions.api_endpoint is not set, GOOGLE_API_USE_MTLS_ENDPOINT="auto" (default), + # GOOGLE_API_USE_CLIENT_CERTIFICATE="false" (default), default cert source doesn't exist, + # and ClientOptions.universe_domain="bar.com", + # use the _DEFAULT_ENDPOINT_TEMPLATE populated with universe domain as the api endpoint. + options = client_options.ClientOptions() + universe_exists = hasattr(options, "universe_domain") + if universe_exists: + options = client_options.ClientOptions(universe_domain=mock_universe) + client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) + else: + client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) + assert client.api_endpoint == (mock_endpoint if universe_exists else default_endpoint) + assert client.universe_domain == (mock_universe if universe_exists else default_universe) + + # If ClientOptions does not have a universe domain attribute and GOOGLE_API_USE_MTLS_ENDPOINT="never", + # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. + options = client_options.ClientOptions() + if hasattr(options, "universe_domain"): + delattr(options, "universe_domain") + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) + assert client.api_endpoint == default_endpoint + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc"), + (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio"), + (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest"), +]) +def test_video_stitcher_service_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", grpc_helpers), + (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), + (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest", None), +]) +def test_video_stitcher_service_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + +def test_video_stitcher_service_client_client_options_from_dict(): + with mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = VideoStitcherServiceClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", grpc_helpers), + (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_video_stitcher_service_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "videostitcher.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=None, + default_host="videostitcher.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateCdnKeyRequest, + dict, +]) +def test_create_cdn_key(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_cdn_key_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.CreateCdnKeyRequest( + parent='parent_value', + cdn_key_id='cdn_key_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_cdn_key(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.CreateCdnKeyRequest( + parent='parent_value', + cdn_key_id='cdn_key_id_value', + ) + +def test_create_cdn_key_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_cdn_key] = mock_rpc + request = {} + client.create_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.create_cdn_key in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.create_cdn_key] = mock_rpc + + request = {} + await client.create_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateCdnKeyRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_cdn_key_async_from_dict(): + await test_create_cdn_key_async(request_type=dict) + +def test_create_cdn_key_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateCdnKeyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_cdn_key_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateCdnKeyRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_cdn_key_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_cdn_key( + parent='parent_value', + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + cdn_key_id='cdn_key_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].cdn_key + mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) + assert arg == mock_val + arg = args[0].cdn_key_id + mock_val = 'cdn_key_id_value' + assert arg == mock_val + + +def test_create_cdn_key_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_cdn_key( + video_stitcher_service.CreateCdnKeyRequest(), + parent='parent_value', + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + cdn_key_id='cdn_key_id_value', + ) + +@pytest.mark.asyncio +async def test_create_cdn_key_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_cdn_key( + parent='parent_value', + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + cdn_key_id='cdn_key_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].cdn_key + mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) + assert arg == mock_val + arg = args[0].cdn_key_id + mock_val = 'cdn_key_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_cdn_key_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_cdn_key( + video_stitcher_service.CreateCdnKeyRequest(), + parent='parent_value', + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + cdn_key_id='cdn_key_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListCdnKeysRequest, + dict, +]) +def test_list_cdn_keys(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListCdnKeysResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_cdn_keys(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListCdnKeysRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCdnKeysPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_cdn_keys_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.ListCdnKeysRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_cdn_keys(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.ListCdnKeysRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_cdn_keys_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_cdn_keys in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_cdn_keys] = mock_rpc + request = {} + client.list_cdn_keys(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_cdn_keys(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_cdn_keys_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.list_cdn_keys in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.list_cdn_keys] = mock_rpc + + request = {} + await client.list_cdn_keys(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_cdn_keys(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_cdn_keys_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListCdnKeysRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_cdn_keys(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListCdnKeysRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCdnKeysAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_cdn_keys_async_from_dict(): + await test_list_cdn_keys_async(request_type=dict) + +def test_list_cdn_keys_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListCdnKeysRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + call.return_value = video_stitcher_service.ListCdnKeysResponse() + client.list_cdn_keys(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_cdn_keys_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListCdnKeysRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse()) + await client.list_cdn_keys(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_cdn_keys_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListCdnKeysResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_cdn_keys( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_cdn_keys_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_cdn_keys( + video_stitcher_service.ListCdnKeysRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_cdn_keys_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListCdnKeysResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_cdn_keys( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_cdn_keys_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_cdn_keys( + video_stitcher_service.ListCdnKeysRequest(), + parent='parent_value', + ) + + +def test_list_cdn_keys_pager(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[], + next_page_token='def', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_cdn_keys(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, cdn_keys.CdnKey) + for i in results) +def test_list_cdn_keys_pages(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[], + next_page_token='def', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + ), + RuntimeError, + ) + pages = list(client.list_cdn_keys(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_cdn_keys_async_pager(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[], + next_page_token='def', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_cdn_keys(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, cdn_keys.CdnKey) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_cdn_keys_async_pages(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[], + next_page_token='def', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_cdn_keys(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetCdnKeyRequest, + dict, +]) +def test_get_cdn_key(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = cdn_keys.CdnKey( + name='name_value', + hostname='hostname_value', + ) + response = client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, cdn_keys.CdnKey) + assert response.name == 'name_value' + assert response.hostname == 'hostname_value' + + +def test_get_cdn_key_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetCdnKeyRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_cdn_key(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetCdnKeyRequest( + name='name_value', + ) + +def test_get_cdn_key_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_cdn_key] = mock_rpc + request = {} + client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_cdn_key in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_cdn_key] = mock_rpc + + request = {} + await client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetCdnKeyRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey( + name='name_value', + hostname='hostname_value', + )) + response = await client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, cdn_keys.CdnKey) + assert response.name == 'name_value' + assert response.hostname == 'hostname_value' + + +@pytest.mark.asyncio +async def test_get_cdn_key_async_from_dict(): + await test_get_cdn_key_async(request_type=dict) + +def test_get_cdn_key_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetCdnKeyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + call.return_value = cdn_keys.CdnKey() + client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_cdn_key_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetCdnKeyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey()) + await client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_cdn_key_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = cdn_keys.CdnKey() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_cdn_key( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_cdn_key_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_cdn_key( + video_stitcher_service.GetCdnKeyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_cdn_key_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = cdn_keys.CdnKey() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_cdn_key( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_cdn_key_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_cdn_key( + video_stitcher_service.GetCdnKeyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteCdnKeyRequest, + dict, +]) +def test_delete_cdn_key(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_cdn_key_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.DeleteCdnKeyRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_cdn_key(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.DeleteCdnKeyRequest( + name='name_value', + ) + +def test_delete_cdn_key_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_cdn_key] = mock_rpc + request = {} + client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.delete_cdn_key in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.delete_cdn_key] = mock_rpc + + request = {} + await client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteCdnKeyRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_cdn_key_async_from_dict(): + await test_delete_cdn_key_async(request_type=dict) + +def test_delete_cdn_key_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteCdnKeyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_cdn_key_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteCdnKeyRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_cdn_key_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_cdn_key( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_cdn_key_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_cdn_key( + video_stitcher_service.DeleteCdnKeyRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_cdn_key_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_cdn_key( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_cdn_key_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_cdn_key( + video_stitcher_service.DeleteCdnKeyRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateCdnKeyRequest, + dict, +]) +def test_update_cdn_key(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_cdn_key_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.UpdateCdnKeyRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_cdn_key(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.UpdateCdnKeyRequest( + ) + +def test_update_cdn_key_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_cdn_key] = mock_rpc + request = {} + client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.update_cdn_key in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.update_cdn_key] = mock_rpc + + request = {} + await client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateCdnKeyRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateCdnKeyRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_cdn_key_async_from_dict(): + await test_update_cdn_key_async(request_type=dict) + +def test_update_cdn_key_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateCdnKeyRequest() + + request.cdn_key.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'cdn_key.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_cdn_key_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateCdnKeyRequest() + + request.cdn_key.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'cdn_key.name=name_value', + ) in kw['metadata'] + + +def test_update_cdn_key_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_cdn_key( + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].cdn_key + mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_cdn_key_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_cdn_key( + video_stitcher_service.UpdateCdnKeyRequest(), + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_cdn_key_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_cdn_key( + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].cdn_key + mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_cdn_key_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_cdn_key( + video_stitcher_service.UpdateCdnKeyRequest(), + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateVodSessionRequest, + dict, +]) +def test_create_vod_session(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + ) + response = client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateVodSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.asset_id == 'asset_id_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == 'vod_config_value' + + +def test_create_vod_session_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.CreateVodSessionRequest( + parent='parent_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_vod_session(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.CreateVodSessionRequest( + parent='parent_value', + ) + +def test_create_vod_session_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_vod_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_vod_session] = mock_rpc + request = {} + client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_vod_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.create_vod_session in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.create_vod_session] = mock_rpc + + request = {} + await client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.create_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_vod_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateVodSessionRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + )) + response = await client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateVodSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.asset_id == 'asset_id_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == 'vod_config_value' + + +@pytest.mark.asyncio +async def test_create_vod_session_async_from_dict(): + await test_create_vod_session_async(request_type=dict) + +def test_create_vod_session_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateVodSessionRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + call.return_value = sessions.VodSession() + client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_vod_session_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateVodSessionRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) + await client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_vod_session_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.VodSession() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_vod_session( + parent='parent_value', + vod_session=sessions.VodSession(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].vod_session + mock_val = sessions.VodSession(name='name_value') + assert arg == mock_val + + +def test_create_vod_session_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_vod_session( + video_stitcher_service.CreateVodSessionRequest(), + parent='parent_value', + vod_session=sessions.VodSession(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_vod_session_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.VodSession() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_vod_session( + parent='parent_value', + vod_session=sessions.VodSession(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].vod_session + mock_val = sessions.VodSession(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_vod_session_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_vod_session( + video_stitcher_service.CreateVodSessionRequest(), + parent='parent_value', + vod_session=sessions.VodSession(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodSessionRequest, + dict, +]) +def test_get_vod_session(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + ) + response = client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.asset_id == 'asset_id_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == 'vod_config_value' + + +def test_get_vod_session_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetVodSessionRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_vod_session(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetVodSessionRequest( + name='name_value', + ) + +def test_get_vod_session_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_session] = mock_rpc + request = {} + client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_vod_session in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_vod_session] = mock_rpc + + request = {} + await client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodSessionRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + )) + response = await client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.asset_id == 'asset_id_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == 'vod_config_value' + + +@pytest.mark.asyncio +async def test_get_vod_session_async_from_dict(): + await test_get_vod_session_async(request_type=dict) + +def test_get_vod_session_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodSessionRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + call.return_value = sessions.VodSession() + client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_vod_session_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodSessionRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) + await client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_vod_session_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.VodSession() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_vod_session( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_vod_session_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_session( + video_stitcher_service.GetVodSessionRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_vod_session_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.VodSession() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_vod_session( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_vod_session_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_vod_session( + video_stitcher_service.GetVodSessionRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListVodStitchDetailsRequest, + dict, +]) +def test_list_vod_stitch_details(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodStitchDetailsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListVodStitchDetailsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodStitchDetailsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_vod_stitch_details_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.ListVodStitchDetailsRequest( + parent='parent_value', + page_token='page_token_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_vod_stitch_details(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.ListVodStitchDetailsRequest( + parent='parent_value', + page_token='page_token_value', + ) + +def test_list_vod_stitch_details_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_vod_stitch_details in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_vod_stitch_details] = mock_rpc + request = {} + client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_stitch_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.list_vod_stitch_details in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.list_vod_stitch_details] = mock_rpc + + request = {} + await client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_vod_stitch_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListVodStitchDetailsRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListVodStitchDetailsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodStitchDetailsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_async_from_dict(): + await test_list_vod_stitch_details_async(request_type=dict) + +def test_list_vod_stitch_details_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListVodStitchDetailsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() + client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListVodStitchDetailsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse()) + await client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_vod_stitch_details_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_vod_stitch_details( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_vod_stitch_details_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_stitch_details( + video_stitcher_service.ListVodStitchDetailsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_vod_stitch_details( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_vod_stitch_details( + video_stitcher_service.ListVodStitchDetailsRequest(), + parent='parent_value', + ) + + +def test_list_vod_stitch_details_pager(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_vod_stitch_details(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, stitch_details.VodStitchDetail) + for i in results) +def test_list_vod_stitch_details_pages(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + ), + RuntimeError, + ) + pages = list(client.list_vod_stitch_details(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_async_pager(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_vod_stitch_details(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, stitch_details.VodStitchDetail) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_vod_stitch_details_async_pages(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_vod_stitch_details(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodStitchDetailRequest, + dict, +]) +def test_get_vod_stitch_detail(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = stitch_details.VodStitchDetail( + name='name_value', + ) + response = client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodStitchDetailRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, stitch_details.VodStitchDetail) + assert response.name == 'name_value' + + +def test_get_vod_stitch_detail_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetVodStitchDetailRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_vod_stitch_detail(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetVodStitchDetailRequest( + name='name_value', + ) + +def test_get_vod_stitch_detail_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_stitch_detail in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_stitch_detail] = mock_rpc + request = {} + client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_stitch_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_vod_stitch_detail in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_vod_stitch_detail] = mock_rpc + + request = {} + await client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_vod_stitch_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodStitchDetailRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail( + name='name_value', + )) + response = await client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodStitchDetailRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, stitch_details.VodStitchDetail) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_async_from_dict(): + await test_get_vod_stitch_detail_async(request_type=dict) + +def test_get_vod_stitch_detail_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodStitchDetailRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + call.return_value = stitch_details.VodStitchDetail() + client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodStitchDetailRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail()) + await client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_vod_stitch_detail_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = stitch_details.VodStitchDetail() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_vod_stitch_detail( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_vod_stitch_detail_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_stitch_detail( + video_stitcher_service.GetVodStitchDetailRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = stitch_details.VodStitchDetail() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_vod_stitch_detail( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_vod_stitch_detail( + video_stitcher_service.GetVodStitchDetailRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListVodAdTagDetailsRequest, + dict, +]) +def test_list_vod_ad_tag_details(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListVodAdTagDetailsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodAdTagDetailsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_vod_ad_tag_details_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.ListVodAdTagDetailsRequest( + parent='parent_value', + page_token='page_token_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_vod_ad_tag_details(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.ListVodAdTagDetailsRequest( + parent='parent_value', + page_token='page_token_value', + ) + +def test_list_vod_ad_tag_details_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_vod_ad_tag_details in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_vod_ad_tag_details] = mock_rpc + request = {} + client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.list_vod_ad_tag_details in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.list_vod_ad_tag_details] = mock_rpc + + request = {} + await client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_vod_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListVodAdTagDetailsRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListVodAdTagDetailsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodAdTagDetailsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_async_from_dict(): + await test_list_vod_ad_tag_details_async(request_type=dict) + +def test_list_vod_ad_tag_details_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListVodAdTagDetailsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListVodAdTagDetailsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse()) + await client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_vod_ad_tag_details_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_vod_ad_tag_details( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_vod_ad_tag_details_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_ad_tag_details( + video_stitcher_service.ListVodAdTagDetailsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_vod_ad_tag_details( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_vod_ad_tag_details( + video_stitcher_service.ListVodAdTagDetailsRequest(), + parent='parent_value', + ) + + +def test_list_vod_ad_tag_details_pager(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_vod_ad_tag_details(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, ad_tag_details.VodAdTagDetail) + for i in results) +def test_list_vod_ad_tag_details_pages(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + ), + RuntimeError, + ) + pages = list(client.list_vod_ad_tag_details(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_async_pager(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_vod_ad_tag_details(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, ad_tag_details.VodAdTagDetail) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_async_pages(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_vod_ad_tag_details(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodAdTagDetailRequest, + dict, +]) +def test_get_vod_ad_tag_detail(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = ad_tag_details.VodAdTagDetail( + name='name_value', + ) + response = client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodAdTagDetailRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.VodAdTagDetail) + assert response.name == 'name_value' + + +def test_get_vod_ad_tag_detail_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetVodAdTagDetailRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_vod_ad_tag_detail(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetVodAdTagDetailRequest( + name='name_value', + ) + +def test_get_vod_ad_tag_detail_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_ad_tag_detail in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_ad_tag_detail] = mock_rpc + request = {} + client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_vod_ad_tag_detail in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_vod_ad_tag_detail] = mock_rpc + + request = {} + await client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_vod_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodAdTagDetailRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail( + name='name_value', + )) + response = await client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodAdTagDetailRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.VodAdTagDetail) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_async_from_dict(): + await test_get_vod_ad_tag_detail_async(request_type=dict) + +def test_get_vod_ad_tag_detail_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodAdTagDetailRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + call.return_value = ad_tag_details.VodAdTagDetail() + client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodAdTagDetailRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail()) + await client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_vod_ad_tag_detail_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = ad_tag_details.VodAdTagDetail() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_vod_ad_tag_detail( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_vod_ad_tag_detail_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_ad_tag_detail( + video_stitcher_service.GetVodAdTagDetailRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = ad_tag_details.VodAdTagDetail() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_vod_ad_tag_detail( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_vod_ad_tag_detail( + video_stitcher_service.GetVodAdTagDetailRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListLiveAdTagDetailsRequest, + dict, +]) +def test_list_live_ad_tag_details(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse( + next_page_token='next_page_token_value', + ) + response = client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListLiveAdTagDetailsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveAdTagDetailsPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_live_ad_tag_details_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.ListLiveAdTagDetailsRequest( + parent='parent_value', + page_token='page_token_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_live_ad_tag_details(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.ListLiveAdTagDetailsRequest( + parent='parent_value', + page_token='page_token_value', + ) + +def test_list_live_ad_tag_details_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_live_ad_tag_details in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_live_ad_tag_details] = mock_rpc + request = {} + client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_live_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.list_live_ad_tag_details in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.list_live_ad_tag_details] = mock_rpc + + request = {} + await client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_live_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListLiveAdTagDetailsRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListLiveAdTagDetailsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveAdTagDetailsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_async_from_dict(): + await test_list_live_ad_tag_details_async(request_type=dict) + +def test_list_live_ad_tag_details_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListLiveAdTagDetailsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListLiveAdTagDetailsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse()) + await client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_live_ad_tag_details_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_live_ad_tag_details( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_live_ad_tag_details_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_live_ad_tag_details( + video_stitcher_service.ListLiveAdTagDetailsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_live_ad_tag_details( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_live_ad_tag_details( + video_stitcher_service.ListLiveAdTagDetailsRequest(), + parent='parent_value', + ) + + +def test_list_live_ad_tag_details_pager(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_live_ad_tag_details(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, ad_tag_details.LiveAdTagDetail) + for i in results) +def test_list_live_ad_tag_details_pages(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + ), + RuntimeError, + ) + pages = list(client.list_live_ad_tag_details(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_async_pager(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_live_ad_tag_details(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, ad_tag_details.LiveAdTagDetail) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_async_pages(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_live_ad_tag_details(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetLiveAdTagDetailRequest, + dict, +]) +def test_get_live_ad_tag_detail(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = ad_tag_details.LiveAdTagDetail( + name='name_value', + ) + response = client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetLiveAdTagDetailRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.LiveAdTagDetail) + assert response.name == 'name_value' + + +def test_get_live_ad_tag_detail_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetLiveAdTagDetailRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_live_ad_tag_detail(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetLiveAdTagDetailRequest( + name='name_value', + ) + +def test_get_live_ad_tag_detail_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_ad_tag_detail in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_live_ad_tag_detail] = mock_rpc + request = {} + client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_live_ad_tag_detail in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_live_ad_tag_detail] = mock_rpc + + request = {} + await client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_live_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetLiveAdTagDetailRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail( + name='name_value', + )) + response = await client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetLiveAdTagDetailRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.LiveAdTagDetail) + assert response.name == 'name_value' + + +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_async_from_dict(): + await test_get_live_ad_tag_detail_async(request_type=dict) + +def test_get_live_ad_tag_detail_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetLiveAdTagDetailRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + call.return_value = ad_tag_details.LiveAdTagDetail() + client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetLiveAdTagDetailRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail()) + await client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_live_ad_tag_detail_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = ad_tag_details.LiveAdTagDetail() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_live_ad_tag_detail( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_live_ad_tag_detail_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_ad_tag_detail( + video_stitcher_service.GetLiveAdTagDetailRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = ad_tag_details.LiveAdTagDetail() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_live_ad_tag_detail( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_live_ad_tag_detail( + video_stitcher_service.GetLiveAdTagDetailRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateSlateRequest, + dict, +]) +def test_create_slate(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_slate_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.CreateSlateRequest( + parent='parent_value', + slate_id='slate_id_value', + request_id='request_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_slate(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.CreateSlateRequest( + parent='parent_value', + slate_id='slate_id_value', + request_id='request_id_value', + ) + +def test_create_slate_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_slate] = mock_rpc + request = {} + client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.create_slate in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.create_slate] = mock_rpc + + request = {} + await client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateSlateRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_slate_async_from_dict(): + await test_create_slate_async(request_type=dict) + +def test_create_slate_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateSlateRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_slate_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateSlateRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_slate_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_slate( + parent='parent_value', + slate=slates.Slate(name='name_value'), + slate_id='slate_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].slate + mock_val = slates.Slate(name='name_value') + assert arg == mock_val + arg = args[0].slate_id + mock_val = 'slate_id_value' + assert arg == mock_val + + +def test_create_slate_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_slate( + video_stitcher_service.CreateSlateRequest(), + parent='parent_value', + slate=slates.Slate(name='name_value'), + slate_id='slate_id_value', + ) + +@pytest.mark.asyncio +async def test_create_slate_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_slate( + parent='parent_value', + slate=slates.Slate(name='name_value'), + slate_id='slate_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].slate + mock_val = slates.Slate(name='name_value') + assert arg == mock_val + arg = args[0].slate_id + mock_val = 'slate_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_slate_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_slate( + video_stitcher_service.CreateSlateRequest(), + parent='parent_value', + slate=slates.Slate(name='name_value'), + slate_id='slate_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListSlatesRequest, + dict, +]) +def test_list_slates(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListSlatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListSlatesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSlatesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_slates_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.ListSlatesRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_slates(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.ListSlatesRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_slates_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_slates in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_slates] = mock_rpc + request = {} + client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_slates(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_slates_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.list_slates in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.list_slates] = mock_rpc + + request = {} + await client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_slates(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_slates_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListSlatesRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListSlatesRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSlatesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_slates_async_from_dict(): + await test_list_slates_async(request_type=dict) + +def test_list_slates_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListSlatesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + call.return_value = video_stitcher_service.ListSlatesResponse() + client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_slates_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListSlatesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse()) + await client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_slates_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListSlatesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_slates( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_slates_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_slates( + video_stitcher_service.ListSlatesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_slates_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListSlatesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_slates( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_slates_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_slates( + video_stitcher_service.ListSlatesRequest(), + parent='parent_value', + ) + + +def test_list_slates_pager(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + slates.Slate(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListSlatesResponse( + slates=[], + next_page_token='def', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_slates(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, slates.Slate) + for i in results) +def test_list_slates_pages(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + slates.Slate(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListSlatesResponse( + slates=[], + next_page_token='def', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + ], + ), + RuntimeError, + ) + pages = list(client.list_slates(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_slates_async_pager(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + slates.Slate(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListSlatesResponse( + slates=[], + next_page_token='def', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_slates(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, slates.Slate) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_slates_async_pages(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + slates.Slate(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListSlatesResponse( + slates=[], + next_page_token='def', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_slates(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetSlateRequest, + dict, +]) +def test_get_slate(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = slates.Slate( + name='name_value', + uri='uri_value', + ) + response = client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, slates.Slate) + assert response.name == 'name_value' + assert response.uri == 'uri_value' + + +def test_get_slate_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetSlateRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_slate(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetSlateRequest( + name='name_value', + ) + +def test_get_slate_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_slate] = mock_rpc + request = {} + client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_slate in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_slate] = mock_rpc + + request = {} + await client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetSlateRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate( + name='name_value', + uri='uri_value', + )) + response = await client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, slates.Slate) + assert response.name == 'name_value' + assert response.uri == 'uri_value' + + +@pytest.mark.asyncio +async def test_get_slate_async_from_dict(): + await test_get_slate_async(request_type=dict) + +def test_get_slate_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetSlateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + call.return_value = slates.Slate() + client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_slate_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetSlateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate()) + await client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_slate_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = slates.Slate() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_slate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_slate_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_slate( + video_stitcher_service.GetSlateRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_slate_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = slates.Slate() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_slate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_slate_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_slate( + video_stitcher_service.GetSlateRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateSlateRequest, + dict, +]) +def test_update_slate(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_slate_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.UpdateSlateRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_slate(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.UpdateSlateRequest( + ) + +def test_update_slate_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_slate] = mock_rpc + request = {} + client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.update_slate in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.update_slate] = mock_rpc + + request = {} + await client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateSlateRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_slate_async_from_dict(): + await test_update_slate_async(request_type=dict) + +def test_update_slate_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateSlateRequest() + + request.slate.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'slate.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_slate_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateSlateRequest() + + request.slate.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'slate.name=name_value', + ) in kw['metadata'] + + +def test_update_slate_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_slate( + slate=slates.Slate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].slate + mock_val = slates.Slate(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_slate_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_slate( + video_stitcher_service.UpdateSlateRequest(), + slate=slates.Slate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_slate_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_slate( + slate=slates.Slate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].slate + mock_val = slates.Slate(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_slate_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_slate( + video_stitcher_service.UpdateSlateRequest(), + slate=slates.Slate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteSlateRequest, + dict, +]) +def test_delete_slate(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_slate_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.DeleteSlateRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_slate(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.DeleteSlateRequest( + name='name_value', + ) + +def test_delete_slate_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_slate] = mock_rpc + request = {} + client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.delete_slate in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.delete_slate] = mock_rpc + + request = {} + await client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteSlateRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteSlateRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_slate_async_from_dict(): + await test_delete_slate_async(request_type=dict) + +def test_delete_slate_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteSlateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_slate_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteSlateRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_slate_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_slate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_slate_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_slate( + video_stitcher_service.DeleteSlateRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_slate_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_slate( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_slate_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_slate( + video_stitcher_service.DeleteSlateRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateLiveSessionRequest, + dict, +]) +def test_create_live_session(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + ) + response = client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateLiveSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.live_config == 'live_config_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +def test_create_live_session_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.CreateLiveSessionRequest( + parent='parent_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_live_session(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.CreateLiveSessionRequest( + parent='parent_value', + ) + +def test_create_live_session_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_live_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_live_session] = mock_rpc + request = {} + client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_live_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.create_live_session in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.create_live_session] = mock_rpc + + request = {} + await client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.create_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_live_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateLiveSessionRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + )) + response = await client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateLiveSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.live_config == 'live_config_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +@pytest.mark.asyncio +async def test_create_live_session_async_from_dict(): + await test_create_live_session_async(request_type=dict) + +def test_create_live_session_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateLiveSessionRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + call.return_value = sessions.LiveSession() + client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_live_session_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateLiveSessionRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) + await client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_live_session_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.LiveSession() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_live_session( + parent='parent_value', + live_session=sessions.LiveSession(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].live_session + mock_val = sessions.LiveSession(name='name_value') + assert arg == mock_val + + +def test_create_live_session_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_live_session( + video_stitcher_service.CreateLiveSessionRequest(), + parent='parent_value', + live_session=sessions.LiveSession(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_live_session_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.LiveSession() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_live_session( + parent='parent_value', + live_session=sessions.LiveSession(name='name_value'), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].live_session + mock_val = sessions.LiveSession(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_live_session_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_live_session( + video_stitcher_service.CreateLiveSessionRequest(), + parent='parent_value', + live_session=sessions.LiveSession(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetLiveSessionRequest, + dict, +]) +def test_get_live_session(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + ) + response = client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetLiveSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.live_config == 'live_config_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +def test_get_live_session_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetLiveSessionRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_live_session(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetLiveSessionRequest( + name='name_value', + ) + +def test_get_live_session_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_live_session] = mock_rpc + request = {} + client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_live_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_live_session in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_live_session] = mock_rpc + + request = {} + await client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_live_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetLiveSessionRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + )) + response = await client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetLiveSessionRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.live_config == 'live_config_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +@pytest.mark.asyncio +async def test_get_live_session_async_from_dict(): + await test_get_live_session_async(request_type=dict) + +def test_get_live_session_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetLiveSessionRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + call.return_value = sessions.LiveSession() + client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_live_session_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetLiveSessionRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) + await client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_live_session_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.LiveSession() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_live_session( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_live_session_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_session( + video_stitcher_service.GetLiveSessionRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_live_session_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = sessions.LiveSession() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_live_session( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_live_session_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_live_session( + video_stitcher_service.GetLiveSessionRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateLiveConfigRequest, + dict, +]) +def test_create_live_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_live_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.CreateLiveConfigRequest( + parent='parent_value', + live_config_id='live_config_id_value', + request_id='request_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_live_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.CreateLiveConfigRequest( + parent='parent_value', + live_config_id='live_config_id_value', + request_id='request_id_value', + ) + +def test_create_live_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_live_config] = mock_rpc + request = {} + client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.create_live_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.create_live_config] = mock_rpc + + request = {} + await client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateLiveConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_live_config_async_from_dict(): + await test_create_live_config_async(request_type=dict) + +def test_create_live_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateLiveConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_live_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateLiveConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_live_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_live_config( + parent='parent_value', + live_config=live_configs.LiveConfig(name='name_value'), + live_config_id='live_config_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].live_config + mock_val = live_configs.LiveConfig(name='name_value') + assert arg == mock_val + arg = args[0].live_config_id + mock_val = 'live_config_id_value' + assert arg == mock_val + + +def test_create_live_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_live_config( + video_stitcher_service.CreateLiveConfigRequest(), + parent='parent_value', + live_config=live_configs.LiveConfig(name='name_value'), + live_config_id='live_config_id_value', + ) + +@pytest.mark.asyncio +async def test_create_live_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_live_config( + parent='parent_value', + live_config=live_configs.LiveConfig(name='name_value'), + live_config_id='live_config_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].live_config + mock_val = live_configs.LiveConfig(name='name_value') + assert arg == mock_val + arg = args[0].live_config_id + mock_val = 'live_config_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_live_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_live_config( + video_stitcher_service.CreateLiveConfigRequest(), + parent='parent_value', + live_config=live_configs.LiveConfig(name='name_value'), + live_config_id='live_config_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListLiveConfigsRequest, + dict, +]) +def test_list_live_configs(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListLiveConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListLiveConfigsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_live_configs_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.ListLiveConfigsRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_live_configs(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.ListLiveConfigsRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_live_configs_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_live_configs in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_live_configs] = mock_rpc + request = {} + client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_live_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_live_configs_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.list_live_configs in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.list_live_configs] = mock_rpc + + request = {} + await client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_live_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_live_configs_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListLiveConfigsRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListLiveConfigsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveConfigsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_live_configs_async_from_dict(): + await test_list_live_configs_async(request_type=dict) + +def test_list_live_configs_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListLiveConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + call.return_value = video_stitcher_service.ListLiveConfigsResponse() + client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_live_configs_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListLiveConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse()) + await client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_live_configs_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListLiveConfigsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_live_configs( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_live_configs_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_live_configs( + video_stitcher_service.ListLiveConfigsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_live_configs_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListLiveConfigsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_live_configs( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_live_configs_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_live_configs( + video_stitcher_service.ListLiveConfigsRequest(), + parent='parent_value', + ) + + +def test_list_live_configs_pager(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_live_configs(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, live_configs.LiveConfig) + for i in results) +def test_list_live_configs_pages(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + ), + RuntimeError, + ) + pages = list(client.list_live_configs(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_live_configs_async_pager(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_live_configs(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, live_configs.LiveConfig) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_live_configs_async_pages(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_live_configs(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetLiveConfigRequest, + dict, +]) +def test_get_live_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = live_configs.LiveConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=live_configs.LiveConfig.State.CREATING, + ad_tracking=live_configs.AdTracking.CLIENT, + default_slate='default_slate_value', + stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, + ) + response = client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, live_configs.LiveConfig) + assert response.name == 'name_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.state == live_configs.LiveConfig.State.CREATING + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.default_slate == 'default_slate_value' + assert response.stitching_policy == live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT + + +def test_get_live_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetLiveConfigRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_live_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetLiveConfigRequest( + name='name_value', + ) + +def test_get_live_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_live_config] = mock_rpc + request = {} + client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_live_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_live_config] = mock_rpc + + request = {} + await client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetLiveConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=live_configs.LiveConfig.State.CREATING, + ad_tracking=live_configs.AdTracking.CLIENT, + default_slate='default_slate_value', + stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, + )) + response = await client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, live_configs.LiveConfig) + assert response.name == 'name_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.state == live_configs.LiveConfig.State.CREATING + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.default_slate == 'default_slate_value' + assert response.stitching_policy == live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT + + +@pytest.mark.asyncio +async def test_get_live_config_async_from_dict(): + await test_get_live_config_async(request_type=dict) + +def test_get_live_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetLiveConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + call.return_value = live_configs.LiveConfig() + client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_live_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetLiveConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig()) + await client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_live_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = live_configs.LiveConfig() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_live_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_live_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_config( + video_stitcher_service.GetLiveConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_live_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = live_configs.LiveConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_live_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_live_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_live_config( + video_stitcher_service.GetLiveConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteLiveConfigRequest, + dict, +]) +def test_delete_live_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_live_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.DeleteLiveConfigRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_live_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.DeleteLiveConfigRequest( + name='name_value', + ) + +def test_delete_live_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_live_config] = mock_rpc + request = {} + client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.delete_live_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.delete_live_config] = mock_rpc + + request = {} + await client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteLiveConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_live_config_async_from_dict(): + await test_delete_live_config_async(request_type=dict) + +def test_delete_live_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteLiveConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_live_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteLiveConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_live_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_live_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_live_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_live_config( + video_stitcher_service.DeleteLiveConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_live_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_live_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_live_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_live_config( + video_stitcher_service.DeleteLiveConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateLiveConfigRequest, + dict, +]) +def test_update_live_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_live_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.UpdateLiveConfigRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_live_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.UpdateLiveConfigRequest( + ) + +def test_update_live_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_live_config] = mock_rpc + request = {} + client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.update_live_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.update_live_config] = mock_rpc + + request = {} + await client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateLiveConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateLiveConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_live_config_async_from_dict(): + await test_update_live_config_async(request_type=dict) + +def test_update_live_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateLiveConfigRequest() + + request.live_config.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'live_config.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_live_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateLiveConfigRequest() + + request.live_config.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'live_config.name=name_value', + ) in kw['metadata'] + + +def test_update_live_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_live_config( + live_config=live_configs.LiveConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].live_config + mock_val = live_configs.LiveConfig(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_live_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_live_config( + video_stitcher_service.UpdateLiveConfigRequest(), + live_config=live_configs.LiveConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_live_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_live_config( + live_config=live_configs.LiveConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].live_config + mock_val = live_configs.LiveConfig(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_live_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_live_config( + video_stitcher_service.UpdateLiveConfigRequest(), + live_config=live_configs.LiveConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateVodConfigRequest, + dict, +]) +def test_create_vod_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_create_vod_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.CreateVodConfigRequest( + parent='parent_value', + vod_config_id='vod_config_id_value', + request_id='request_id_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.create_vod_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.CreateVodConfigRequest( + parent='parent_value', + vod_config_id='vod_config_id_value', + request_id='request_id_value', + ) + +def test_create_vod_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_vod_config] = mock_rpc + request = {} + client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.create_vod_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.create_vod_config] = mock_rpc + + request = {} + await client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.create_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_create_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateVodConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.CreateVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_create_vod_config_async_from_dict(): + await test_create_vod_config_async(request_type=dict) + +def test_create_vod_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateVodConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_create_vod_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.CreateVodConfigRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_create_vod_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_vod_config( + parent='parent_value', + vod_config=vod_configs.VodConfig(name='name_value'), + vod_config_id='vod_config_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].vod_config + mock_val = vod_configs.VodConfig(name='name_value') + assert arg == mock_val + arg = args[0].vod_config_id + mock_val = 'vod_config_id_value' + assert arg == mock_val + + +def test_create_vod_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_vod_config( + video_stitcher_service.CreateVodConfigRequest(), + parent='parent_value', + vod_config=vod_configs.VodConfig(name='name_value'), + vod_config_id='vod_config_id_value', + ) + +@pytest.mark.asyncio +async def test_create_vod_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_vod_config( + parent='parent_value', + vod_config=vod_configs.VodConfig(name='name_value'), + vod_config_id='vod_config_id_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + arg = args[0].vod_config + mock_val = vod_configs.VodConfig(name='name_value') + assert arg == mock_val + arg = args[0].vod_config_id + mock_val = 'vod_config_id_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_vod_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_vod_config( + video_stitcher_service.CreateVodConfigRequest(), + parent='parent_value', + vod_config=vod_configs.VodConfig(name='name_value'), + vod_config_id='vod_config_id_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListVodConfigsRequest, + dict, +]) +def test_list_vod_configs(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + response = client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListVodConfigsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +def test_list_vod_configs_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.ListVodConfigsRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.list_vod_configs(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.ListVodConfigsRequest( + parent='parent_value', + page_token='page_token_value', + filter='filter_value', + order_by='order_by_value', + ) + +def test_list_vod_configs_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_vod_configs in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_vod_configs] = mock_rpc + request = {} + client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_vod_configs_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.list_vod_configs in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.list_vod_configs] = mock_rpc + + request = {} + await client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.list_vod_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_list_vod_configs_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListVodConfigsRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + response = await client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.ListVodConfigsRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodConfigsAsyncPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.asyncio +async def test_list_vod_configs_async_from_dict(): + await test_list_vod_configs_async(request_type=dict) + +def test_list_vod_configs_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListVodConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + call.return_value = video_stitcher_service.ListVodConfigsResponse() + client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_list_vod_configs_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.ListVodConfigsRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse()) + await client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'parent=parent_value', + ) in kw['metadata'] + + +def test_list_vod_configs_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodConfigsResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_vod_configs( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + + +def test_list_vod_configs_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_configs( + video_stitcher_service.ListVodConfigsRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_vod_configs_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = video_stitcher_service.ListVodConfigsResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_vod_configs( + parent='parent_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = 'parent_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_list_vod_configs_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_vod_configs( + video_stitcher_service.ListVodConfigsRequest(), + parent='parent_value', + ) + + +def test_list_vod_configs_pager(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + ), + RuntimeError, + ) + + expected_metadata = () + retry = retries.Retry() + timeout = 5 + expected_metadata = tuple(expected_metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_vod_configs(request={}, retry=retry, timeout=timeout) + + assert pager._metadata == expected_metadata + assert pager._retry == retry + assert pager._timeout == timeout + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, vod_configs.VodConfig) + for i in results) +def test_list_vod_configs_pages(transport_name: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + ), + RuntimeError, + ) + pages = list(client.list_vod_configs(request={}).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.asyncio +async def test_list_vod_configs_async_pager(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_vod_configs(request={},) + assert async_pager.next_page_token == 'abc' + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, vod_configs.VodConfig) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_vod_configs_async_pages(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_vod_configs(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodConfigRequest, + dict, +]) +def test_get_vod_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = vod_configs.VodConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=vod_configs.VodConfig.State.CREATING, + ) + response = client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, vod_configs.VodConfig) + assert response.name == 'name_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.state == vod_configs.VodConfig.State.CREATING + + +def test_get_vod_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.GetVodConfigRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.get_vod_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.GetVodConfigRequest( + name='name_value', + ) + +def test_get_vod_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_config] = mock_rpc + request = {} + client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.get_vod_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.get_vod_config] = mock_rpc + + request = {} + await client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + await client.get_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_get_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=vod_configs.VodConfig.State.CREATING, + )) + response = await client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.GetVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, vod_configs.VodConfig) + assert response.name == 'name_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.state == vod_configs.VodConfig.State.CREATING + + +@pytest.mark.asyncio +async def test_get_vod_config_async_from_dict(): + await test_get_vod_config_async(request_type=dict) + +def test_get_vod_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + call.return_value = vod_configs.VodConfig() + client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_get_vod_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.GetVodConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig()) + await client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_get_vod_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = vod_configs.VodConfig() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_vod_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_get_vod_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_config( + video_stitcher_service.GetVodConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_vod_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = vod_configs.VodConfig() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_vod_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_get_vod_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_vod_config( + video_stitcher_service.GetVodConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteVodConfigRequest, + dict, +]) +def test_delete_vod_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_delete_vod_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.DeleteVodConfigRequest( + name='name_value', + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.delete_vod_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.DeleteVodConfigRequest( + name='name_value', + ) + +def test_delete_vod_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_vod_config] = mock_rpc + request = {} + client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.delete_vod_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.delete_vod_config] = mock_rpc + + request = {} + await client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.delete_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_delete_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteVodConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.DeleteVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_delete_vod_config_async_from_dict(): + await test_delete_vod_config_async(request_type=dict) + +def test_delete_vod_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteVodConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_delete_vod_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.DeleteVodConfigRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'name=name_value', + ) in kw['metadata'] + + +def test_delete_vod_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_vod_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + + +def test_delete_vod_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_vod_config( + video_stitcher_service.DeleteVodConfigRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_vod_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_vod_config( + name='name_value', + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = 'name_value' + assert arg == mock_val + +@pytest.mark.asyncio +async def test_delete_vod_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_vod_config( + video_stitcher_service.DeleteVodConfigRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateVodConfigRequest, + dict, +]) +def test_update_vod_config(request_type, transport: str = 'grpc'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/spam') + response = client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +def test_update_vod_config_non_empty_request_with_auto_populated_field(): + # This test is a coverage failsafe to make sure that UUID4 fields are + # automatically populated, according to AIP-4235, with non-empty requests. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + + # Populate all string fields in the request which are not UUID4 + # since we want to check that UUID4 are populated automatically + # if they meet the requirements of AIP 4235. + request = video_stitcher_service.UpdateVodConfigRequest( + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client.update_vod_config(request=request) + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == video_stitcher_service.UpdateVodConfigRequest( + ) + +def test_update_vod_config_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_vod_config] = mock_rpc + request = {} + client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._client._transport.update_vod_config in client._client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.AsyncMock() + mock_rpc.return_value = mock.Mock() + client._client._transport._wrapped_methods[client._client._transport.update_vod_config] = mock_rpc + + request = {} + await client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods call wrapper_fn to build a cached + # client._transport.operations_client instance on first rpc call. + # Subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + await client.update_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + +@pytest.mark.asyncio +async def test_update_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateVodConfigRequest): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + response = await client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + request = video_stitcher_service.UpdateVodConfigRequest() + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, future.Future) + + +@pytest.mark.asyncio +async def test_update_vod_config_async_from_dict(): + await test_update_vod_config_async(request_type=dict) + +def test_update_vod_config_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateVodConfigRequest() + + request.vod_config.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'vod_config.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_vod_config_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = video_stitcher_service.UpdateVodConfigRequest() + + request.vod_config.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) + await client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + 'x-goog-request-params', + 'vod_config.name=name_value', + ) in kw['metadata'] + + +def test_update_vod_config_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_vod_config( + vod_config=vod_configs.VodConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].vod_config + mock_val = vod_configs.VodConfig(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + + +def test_update_vod_config_flattened_error(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_vod_config( + video_stitcher_service.UpdateVodConfigRequest(), + vod_config=vod_configs.VodConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_vod_config_flattened_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation(name='operations/op') + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_vod_config( + vod_config=vod_configs.VodConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].vod_config + mock_val = vod_configs.VodConfig(name='name_value') + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) + assert arg == mock_val + +@pytest.mark.asyncio +async def test_update_vod_config_flattened_error_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_vod_config( + video_stitcher_service.UpdateVodConfigRequest(), + vod_config=vod_configs.VodConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_cdn_key] = mock_rpc + + request = {} + client.create_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_cdn_key_rest_required_fields(request_type=video_stitcher_service.CreateCdnKeyRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["cdn_key_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "cdnKeyId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "cdnKeyId" in jsonified_request + assert jsonified_request["cdnKeyId"] == request_init["cdn_key_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["cdnKeyId"] = 'cdn_key_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_cdn_key._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("cdn_key_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "cdnKeyId" in jsonified_request + assert jsonified_request["cdnKeyId"] == 'cdn_key_id_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_cdn_key(request) + + expected_params = [ + ( + "cdnKeyId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == (set(("cdnKeyId", )) & set(("parent", "cdnKey", "cdnKeyId", ))) + + +def test_create_cdn_key_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + cdn_key_id='cdn_key_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/cdnKeys" % client.transport._host, args[1]) + + +def test_create_cdn_key_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_cdn_key( + video_stitcher_service.CreateCdnKeyRequest(), + parent='parent_value', + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + cdn_key_id='cdn_key_id_value', + ) + + +def test_list_cdn_keys_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_cdn_keys in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_cdn_keys] = mock_rpc + + request = {} + client.list_cdn_keys(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_cdn_keys(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_cdn_keys_rest_required_fields(request_type=video_stitcher_service.ListCdnKeysRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_cdn_keys._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_cdn_keys._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListCdnKeysResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_cdn_keys(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_cdn_keys_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_cdn_keys._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_cdn_keys_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListCdnKeysResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_cdn_keys(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/cdnKeys" % client.transport._host, args[1]) + + +def test_list_cdn_keys_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_cdn_keys( + video_stitcher_service.ListCdnKeysRequest(), + parent='parent_value', + ) + + +def test_list_cdn_keys_rest_pager(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[], + next_page_token='def', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(video_stitcher_service.ListCdnKeysResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_cdn_keys(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, cdn_keys.CdnKey) + for i in results) + + pages = list(client.list_cdn_keys(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_cdn_key] = mock_rpc + + request = {} + client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_cdn_key_rest_required_fields(request_type=video_stitcher_service.GetCdnKeyRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = cdn_keys.CdnKey() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = cdn_keys.CdnKey.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_cdn_key(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_cdn_key_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = cdn_keys.CdnKey() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = cdn_keys.CdnKey.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, args[1]) + + +def test_get_cdn_key_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_cdn_key( + video_stitcher_service.GetCdnKeyRequest(), + name='name_value', + ) + + +def test_delete_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_cdn_key] = mock_rpc + + request = {} + client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_cdn_key_rest_required_fields(request_type=video_stitcher_service.DeleteCdnKeyRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_cdn_key(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_cdn_key_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, args[1]) + + +def test_delete_cdn_key_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_cdn_key( + video_stitcher_service.DeleteCdnKeyRequest(), + name='name_value', + ) + + +def test_update_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_cdn_key] = mock_rpc + + request = {} + client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_cdn_key_rest_required_fields(request_type=video_stitcher_service.UpdateCdnKeyRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_cdn_key._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_cdn_key(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("cdnKey", "updateMask", ))) + + +def test_update_cdn_key_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'cdn_key': {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{cdn_key.name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, args[1]) + + +def test_update_cdn_key_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_cdn_key( + video_stitcher_service.UpdateCdnKeyRequest(), + cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_vod_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_vod_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_vod_session] = mock_rpc + + request = {} + client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_vod_session_rest_required_fields(request_type=video_stitcher_service.CreateVodSessionRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_vod_session(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_vod_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_vod_session._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "vodSession", ))) + + +def test_create_vod_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + vod_session=sessions.VodSession(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_vod_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/vodSessions" % client.transport._host, args[1]) + + +def test_create_vod_session_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_vod_session( + video_stitcher_service.CreateVodSessionRequest(), + parent='parent_value', + vod_session=sessions.VodSession(name='name_value'), + ) + + +def test_get_vod_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_session] = mock_rpc + + request = {} + client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_session_rest_required_fields(request_type=video_stitcher_service.GetVodSessionRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_session(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_vod_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_vod_session._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_vod_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodSessions/*}" % client.transport._host, args[1]) + + +def test_get_vod_session_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_session( + video_stitcher_service.GetVodSessionRequest(), + name='name_value', + ) + + +def test_list_vod_stitch_details_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_vod_stitch_details in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_vod_stitch_details] = mock_rpc + + request = {} + client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_stitch_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_vod_stitch_details_rest_required_fields(request_type=video_stitcher_service.ListVodStitchDetailsRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_stitch_details._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_stitch_details._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodStitchDetailsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_vod_stitch_details(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_vod_stitch_details_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_vod_stitch_details._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_vod_stitch_details_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodStitchDetailsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_vod_stitch_details(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/vodSessions/*}/vodStitchDetails" % client.transport._host, args[1]) + + +def test_list_vod_stitch_details_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_stitch_details( + video_stitcher_service.ListVodStitchDetailsRequest(), + parent='parent_value', + ) + + +def test_list_vod_stitch_details_rest_pager(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(video_stitcher_service.ListVodStitchDetailsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + + pager = client.list_vod_stitch_details(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, stitch_details.VodStitchDetail) + for i in results) + + pages = list(client.list_vod_stitch_details(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_vod_stitch_detail_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_stitch_detail in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_stitch_detail] = mock_rpc + + request = {} + client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_stitch_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_stitch_detail_rest_required_fields(request_type=video_stitcher_service.GetVodStitchDetailRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_stitch_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_stitch_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = stitch_details.VodStitchDetail() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = stitch_details.VodStitchDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_stitch_detail(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_vod_stitch_detail_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_vod_stitch_detail._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_vod_stitch_detail_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = stitch_details.VodStitchDetail() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = stitch_details.VodStitchDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_stitch_detail(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodSessions/*/vodStitchDetails/*}" % client.transport._host, args[1]) + + +def test_get_vod_stitch_detail_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_stitch_detail( + video_stitcher_service.GetVodStitchDetailRequest(), + name='name_value', + ) + + +def test_list_vod_ad_tag_details_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_vod_ad_tag_details in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_vod_ad_tag_details] = mock_rpc + + request = {} + client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_vod_ad_tag_details_rest_required_fields(request_type=video_stitcher_service.ListVodAdTagDetailsRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_ad_tag_details._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_ad_tag_details._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_vod_ad_tag_details(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_vod_ad_tag_details_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_vod_ad_tag_details._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_vod_ad_tag_details_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_vod_ad_tag_details(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/vodSessions/*}/vodAdTagDetails" % client.transport._host, args[1]) + + +def test_list_vod_ad_tag_details_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_ad_tag_details( + video_stitcher_service.ListVodAdTagDetailsRequest(), + parent='parent_value', + ) + + +def test_list_vod_ad_tag_details_rest_pager(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(video_stitcher_service.ListVodAdTagDetailsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + + pager = client.list_vod_ad_tag_details(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, ad_tag_details.VodAdTagDetail) + for i in results) + + pages = list(client.list_vod_ad_tag_details(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_vod_ad_tag_detail_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_ad_tag_detail in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_ad_tag_detail] = mock_rpc + + request = {} + client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_ad_tag_detail_rest_required_fields(request_type=video_stitcher_service.GetVodAdTagDetailRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.VodAdTagDetail() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.VodAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_ad_tag_detail(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_vod_ad_tag_detail_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_vod_ad_tag_detail._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_vod_ad_tag_detail_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.VodAdTagDetail() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = ad_tag_details.VodAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_ad_tag_detail(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodSessions/*/vodAdTagDetails/*}" % client.transport._host, args[1]) + + +def test_get_vod_ad_tag_detail_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_ad_tag_detail( + video_stitcher_service.GetVodAdTagDetailRequest(), + name='name_value', + ) + + +def test_list_live_ad_tag_details_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_live_ad_tag_details in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_live_ad_tag_details] = mock_rpc + + request = {} + client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_live_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_live_ad_tag_details_rest_required_fields(request_type=video_stitcher_service.ListLiveAdTagDetailsRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_ad_tag_details._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_ad_tag_details._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_live_ad_tag_details(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_live_ad_tag_details_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_live_ad_tag_details._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_live_ad_tag_details_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_live_ad_tag_details(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*/liveSessions/*}/liveAdTagDetails" % client.transport._host, args[1]) + + +def test_list_live_ad_tag_details_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_live_ad_tag_details( + video_stitcher_service.ListLiveAdTagDetailsRequest(), + parent='parent_value', + ) + + +def test_list_live_ad_tag_details_rest_pager(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(video_stitcher_service.ListLiveAdTagDetailsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} + + pager = client.list_live_ad_tag_details(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, ad_tag_details.LiveAdTagDetail) + for i in results) + + pages = list(client.list_live_ad_tag_details(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_live_ad_tag_detail_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_ad_tag_detail in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_live_ad_tag_detail] = mock_rpc + + request = {} + client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_live_ad_tag_detail_rest_required_fields(request_type=video_stitcher_service.GetLiveAdTagDetailRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.LiveAdTagDetail() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_live_ad_tag_detail(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_live_ad_tag_detail_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_live_ad_tag_detail._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_live_ad_tag_detail_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.LiveAdTagDetail() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_live_ad_tag_detail(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveSessions/*/liveAdTagDetails/*}" % client.transport._host, args[1]) + + +def test_get_live_ad_tag_detail_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_ad_tag_detail( + video_stitcher_service.GetLiveAdTagDetailRequest(), + name='name_value', + ) + + +def test_create_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_slate] = mock_rpc + + request = {} + client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_slate_rest_required_fields(request_type=video_stitcher_service.CreateSlateRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["slate_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "slateId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "slateId" in jsonified_request + assert jsonified_request["slateId"] == request_init["slate_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["slateId"] = 'slate_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_slate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id", "slate_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "slateId" in jsonified_request + assert jsonified_request["slateId"] == 'slate_id_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_slate(request) + + expected_params = [ + ( + "slateId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_slate._get_unset_required_fields({}) + assert set(unset_fields) == (set(("requestId", "slateId", )) & set(("parent", "slateId", "slate", ))) + + +def test_create_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + slate=slates.Slate(name='name_value'), + slate_id='slate_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/slates" % client.transport._host, args[1]) + + +def test_create_slate_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_slate( + video_stitcher_service.CreateSlateRequest(), + parent='parent_value', + slate=slates.Slate(name='name_value'), + slate_id='slate_id_value', + ) + + +def test_list_slates_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_slates in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_slates] = mock_rpc + + request = {} + client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_slates(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_slates_rest_required_fields(request_type=video_stitcher_service.ListSlatesRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_slates._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_slates._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListSlatesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_slates(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_slates_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_slates._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_slates_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListSlatesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_slates(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/slates" % client.transport._host, args[1]) + + +def test_list_slates_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_slates( + video_stitcher_service.ListSlatesRequest(), + parent='parent_value', + ) + + +def test_list_slates_rest_pager(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + slates.Slate(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListSlatesResponse( + slates=[], + next_page_token='def', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(video_stitcher_service.ListSlatesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_slates(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, slates.Slate) + for i in results) + + pages = list(client.list_slates(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_slate] = mock_rpc + + request = {} + client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_slate_rest_required_fields(request_type=video_stitcher_service.GetSlateRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = slates.Slate() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = slates.Slate.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_slate(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_slate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = slates.Slate() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/slates/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = slates.Slate.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/slates/*}" % client.transport._host, args[1]) + + +def test_get_slate_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_slate( + video_stitcher_service.GetSlateRequest(), + name='name_value', + ) + + +def test_update_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_slate] = mock_rpc + + request = {} + client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_slate_rest_required_fields(request_type=video_stitcher_service.UpdateSlateRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_slate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_slate(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_slate._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("slate", "updateMask", ))) + + +def test_update_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'slate': {'name': 'projects/sample1/locations/sample2/slates/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + slate=slates.Slate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{slate.name=projects/*/locations/*/slates/*}" % client.transport._host, args[1]) + + +def test_update_slate_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_slate( + video_stitcher_service.UpdateSlateRequest(), + slate=slates.Slate(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_delete_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_slate] = mock_rpc + + request = {} + client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_slate_rest_required_fields(request_type=video_stitcher_service.DeleteSlateRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_slate(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_slate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/slates/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/slates/*}" % client.transport._host, args[1]) + + +def test_delete_slate_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_slate( + video_stitcher_service.DeleteSlateRequest(), + name='name_value', + ) + + +def test_create_live_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_live_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_live_session] = mock_rpc + + request = {} + client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_live_session_rest_required_fields(request_type=video_stitcher_service.CreateLiveSessionRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_live_session(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_live_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_live_session._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "liveSession", ))) + + +def test_create_live_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + live_session=sessions.LiveSession(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_live_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/liveSessions" % client.transport._host, args[1]) + + +def test_create_live_session_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_live_session( + video_stitcher_service.CreateLiveSessionRequest(), + parent='parent_value', + live_session=sessions.LiveSession(name='name_value'), + ) + + +def test_get_live_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_live_session] = mock_rpc + + request = {} + client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_live_session_rest_required_fields(request_type=video_stitcher_service.GetLiveSessionRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_live_session(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_live_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_live_session._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_live_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_live_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveSessions/*}" % client.transport._host, args[1]) + + +def test_get_live_session_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_session( + video_stitcher_service.GetLiveSessionRequest(), + name='name_value', + ) + + +def test_create_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_live_config] = mock_rpc + + request = {} + client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_live_config_rest_required_fields(request_type=video_stitcher_service.CreateLiveConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["live_config_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "liveConfigId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "liveConfigId" in jsonified_request + assert jsonified_request["liveConfigId"] == request_init["live_config_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["liveConfigId"] = 'live_config_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("live_config_id", "request_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "liveConfigId" in jsonified_request + assert jsonified_request["liveConfigId"] == 'live_config_id_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_live_config(request) + + expected_params = [ + ( + "liveConfigId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_live_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("liveConfigId", "requestId", )) & set(("parent", "liveConfigId", "liveConfig", ))) + + +def test_create_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + live_config=live_configs.LiveConfig(name='name_value'), + live_config_id='live_config_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/liveConfigs" % client.transport._host, args[1]) + + +def test_create_live_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_live_config( + video_stitcher_service.CreateLiveConfigRequest(), + parent='parent_value', + live_config=live_configs.LiveConfig(name='name_value'), + live_config_id='live_config_id_value', + ) + + +def test_list_live_configs_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_live_configs in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_live_configs] = mock_rpc + + request = {} + client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_live_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_live_configs_rest_required_fields(request_type=video_stitcher_service.ListLiveConfigsRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveConfigsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_live_configs(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_live_configs_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_live_configs._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_live_configs_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveConfigsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_live_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/liveConfigs" % client.transport._host, args[1]) + + +def test_list_live_configs_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_live_configs( + video_stitcher_service.ListLiveConfigsRequest(), + parent='parent_value', + ) + + +def test_list_live_configs_rest_pager(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(video_stitcher_service.ListLiveConfigsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_live_configs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, live_configs.LiveConfig) + for i in results) + + pages = list(client.list_live_configs(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_live_config] = mock_rpc + + request = {} + client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_live_config_rest_required_fields(request_type=video_stitcher_service.GetLiveConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = live_configs.LiveConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = live_configs.LiveConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_live_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_live_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = live_configs.LiveConfig() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = live_configs.LiveConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveConfigs/*}" % client.transport._host, args[1]) + + +def test_get_live_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_config( + video_stitcher_service.GetLiveConfigRequest(), + name='name_value', + ) + + +def test_delete_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_live_config] = mock_rpc + + request = {} + client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_live_config_rest_required_fields(request_type=video_stitcher_service.DeleteLiveConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_live_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_live_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveConfigs/*}" % client.transport._host, args[1]) + + +def test_delete_live_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_live_config( + video_stitcher_service.DeleteLiveConfigRequest(), + name='name_value', + ) + + +def test_update_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_live_config] = mock_rpc + + request = {} + client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_live_config_rest_required_fields(request_type=video_stitcher_service.UpdateLiveConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_live_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_live_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_live_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("liveConfig", "updateMask", ))) + + +def test_update_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'live_config': {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + live_config=live_configs.LiveConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{live_config.name=projects/*/locations/*/liveConfigs/*}" % client.transport._host, args[1]) + + +def test_update_live_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_live_config( + video_stitcher_service.UpdateLiveConfigRequest(), + live_config=live_configs.LiveConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_create_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.create_vod_config] = mock_rpc + + request = {} + client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_vod_config_rest_required_fields(request_type=video_stitcher_service.CreateVodConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["vod_config_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + assert "vodConfigId" not in jsonified_request + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "vodConfigId" in jsonified_request + assert jsonified_request["vodConfigId"] == request_init["vod_config_id"] + + jsonified_request["parent"] = 'parent_value' + jsonified_request["vodConfigId"] = 'vod_config_id_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("request_id", "vod_config_id", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "vodConfigId" in jsonified_request + assert jsonified_request["vodConfigId"] == 'vod_config_id_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_vod_config(request) + + expected_params = [ + ( + "vodConfigId", + "", + ), + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("requestId", "vodConfigId", )) & set(("parent", "vodConfigId", "vodConfig", ))) + + +def test_create_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + vod_config=vod_configs.VodConfig(name='name_value'), + vod_config_id='vod_config_id_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/vodConfigs" % client.transport._host, args[1]) + + +def test_create_vod_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_vod_config( + video_stitcher_service.CreateVodConfigRequest(), + parent='parent_value', + vod_config=vod_configs.VodConfig(name='name_value'), + vod_config_id='vod_config_id_value', + ) + + +def test_list_vod_configs_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_vod_configs in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.list_vod_configs] = mock_rpc + + request = {} + client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_vod_configs_rest_required_fields(request_type=video_stitcher_service.ListVodConfigsRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodConfigsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_vod_configs(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_vod_configs_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_vod_configs._get_unset_required_fields({}) + assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) + + +def test_list_vod_configs_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodConfigsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_vod_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/vodConfigs" % client.transport._host, args[1]) + + +def test_list_vod_configs_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_configs( + video_stitcher_service.ListVodConfigsRequest(), + parent='parent_value', + ) + + +def test_list_vod_configs_rest_pager(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + next_page_token='abc', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[], + next_page_token='def', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + ], + next_page_token='ghi', + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(video_stitcher_service.ListVodConfigsResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_vod_configs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, vod_configs.VodConfig) + for i in results) + + pages = list(client.list_vod_configs(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +def test_get_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.get_vod_config] = mock_rpc + + request = {} + client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_config_rest_required_fields(request_type=video_stitcher_service.GetVodConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = vod_configs.VodConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = vod_configs.VodConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_get_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = vod_configs.VodConfig() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = vod_configs.VodConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, args[1]) + + +def test_get_vod_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_config( + video_stitcher_service.GetVodConfigRequest(), + name='name_value', + ) + + +def test_delete_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.delete_vod_config] = mock_rpc + + request = {} + client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_vod_config_rest_required_fields(request_type=video_stitcher_service.DeleteVodConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_vod_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +def test_delete_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, args[1]) + + +def test_delete_vod_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_vod_config( + video_stitcher_service.DeleteVodConfigRequest(), + name='name_value', + ) + + +def test_update_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. + client._transport._wrapped_methods[client._transport.update_vod_config] = mock_rpc + + request = {} + client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_vod_config_rest_required_fields(request_type=video_stitcher_service.UpdateVodConfigRequest): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_vod_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_vod_config(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", )) & set(("vodConfig", "updateMask", ))) + + +def test_update_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # get arguments that satisfy an http rule for this method + sample_request = {'vod_config': {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + vod_config=vod_configs.VodConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{vod_config.name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, args[1]) + + +def test_update_vod_config_rest_flattened_error(transport: str = 'rest'): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_vod_config( + video_stitcher_service.UpdateVodConfigRequest(), + vod_config=vod_configs.VodConfig(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = VideoStitcherServiceClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.VideoStitcherServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.VideoStitcherServiceGrpcTransport, + transports.VideoStitcherServiceGrpcAsyncIOTransport, + transports.VideoStitcherServiceRestTransport, +]) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + +def test_transport_kind_grpc(): + transport = VideoStitcherServiceClient.get_transport_class("grpc")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "grpc" + + +def test_initialize_client_w_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_cdn_keys_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + call.return_value = video_stitcher_service.ListCdnKeysResponse() + client.list_cdn_keys(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListCdnKeysRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + call.return_value = cdn_keys.CdnKey() + client.get_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_vod_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + call.return_value = sessions.VodSession() + client.create_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + call.return_value = sessions.VodSession() + client.get_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_stitch_details_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() + client.list_vod_stitch_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodStitchDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_stitch_detail_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + call.return_value = stitch_details.VodStitchDetail() + client.get_vod_stitch_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodStitchDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_ad_tag_details_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + client.list_vod_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_ad_tag_detail_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + call.return_value = ad_tag_details.VodAdTagDetail() + client.get_vod_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_live_ad_tag_details_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + client.list_live_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_ad_tag_detail_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + call.return_value = ad_tag_details.LiveAdTagDetail() + client.get_live_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_slates_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + call.return_value = video_stitcher_service.ListSlatesResponse() + client.list_slates(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListSlatesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + call.return_value = slates.Slate() + client.get_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_live_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + call.return_value = sessions.LiveSession() + client.create_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + call.return_value = sessions.LiveSession() + client.get_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_live_configs_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + call.return_value = video_stitcher_service.ListLiveConfigsResponse() + client.list_live_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + call.return_value = live_configs.LiveConfig() + client.get_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.create_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_configs_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + call.return_value = video_stitcher_service.ListVodConfigsResponse() + client.list_vod_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + call.return_value = vod_configs.VodConfig() + client.get_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.delete_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + call.return_value = operations_pb2.Operation(name='operations/op') + client.update_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateVodConfigRequest() + + assert args[0] == request_msg + + +def test_transport_kind_grpc_asyncio(): + transport = VideoStitcherServiceAsyncClient.get_transport_class("grpc_asyncio")( + credentials=async_anonymous_credentials() + ) + assert transport.kind == "grpc_asyncio" + + +def test_initialize_client_w_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.create_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_cdn_keys_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_cdn_keys(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListCdnKeysRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey( + name='name_value', + hostname='hostname_value', + )) + await client.get_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.delete_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.update_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_vod_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + )) + await client.create_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + )) + await client.get_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_vod_stitch_details_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse( + next_page_token='next_page_token_value', + )) + await client.list_vod_stitch_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodStitchDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail( + name='name_value', + )) + await client.get_vod_stitch_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodStitchDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse( + next_page_token='next_page_token_value', + )) + await client.list_vod_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail( + name='name_value', + )) + await client.get_vod_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse( + next_page_token='next_page_token_value', + )) + await client.list_live_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail( + name='name_value', + )) + await client.get_live_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.create_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_slates_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_slates(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListSlatesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate( + name='name_value', + uri='uri_value', + )) + await client.get_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.update_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.delete_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_live_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + )) + await client.create_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_live_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + )) + await client.get_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.create_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_live_configs_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_live_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=live_configs.LiveConfig.State.CREATING, + ad_tracking=live_configs.AdTracking.CLIENT, + default_slate='default_slate_value', + stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, + )) + await client.get_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.delete_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.update_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.create_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_vod_configs_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + )) + await client.list_vod_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=vod_configs.VodConfig.State.CREATING, + )) + await client.get_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.delete_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name='operations/spam') + ) + await client.update_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateVodConfigRequest() + + assert args[0] == request_msg + + +def test_transport_kind_rest(): + transport = VideoStitcherServiceClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_create_cdn_key_rest_bad_request(request_type=video_stitcher_service.CreateCdnKeyRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_cdn_key(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateCdnKeyRequest, + dict, +]) +def test_create_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["cdn_key"] = {'google_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value'}, 'akamai_cdn_key': {'token_key': b'token_key_blob'}, 'media_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value', 'token_config': {'query_parameter': 'query_parameter_value'}}, 'name': 'name_value', 'hostname': 'hostname_value'} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateCdnKeyRequest.meta.fields["cdn_key"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["cdn_key"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["cdn_key"][field])): + del request_init["cdn_key"][field][i][subfield] + else: + del request_init["cdn_key"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_cdn_key(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_cdn_key") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_cdn_key_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_cdn_key") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateCdnKeyRequest.pb(video_stitcher_service.CreateCdnKeyRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateCdnKeyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_cdn_keys_rest_bad_request(request_type=video_stitcher_service.ListCdnKeysRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_cdn_keys(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListCdnKeysRequest, + dict, +]) +def test_list_cdn_keys_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListCdnKeysResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_cdn_keys(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCdnKeysPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_cdn_keys_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_cdn_keys") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_cdn_keys_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_cdn_keys") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListCdnKeysRequest.pb(video_stitcher_service.ListCdnKeysRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListCdnKeysResponse.to_json(video_stitcher_service.ListCdnKeysResponse()) + req.return_value.content = return_value + + request = video_stitcher_service.ListCdnKeysRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListCdnKeysResponse() + post_with_metadata.return_value = video_stitcher_service.ListCdnKeysResponse(), metadata + + client.list_cdn_keys(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_cdn_key_rest_bad_request(request_type=video_stitcher_service.GetCdnKeyRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_cdn_key(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetCdnKeyRequest, + dict, +]) +def test_get_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = cdn_keys.CdnKey( + name='name_value', + hostname='hostname_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = cdn_keys.CdnKey.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_cdn_key(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, cdn_keys.CdnKey) + assert response.name == 'name_value' + assert response.hostname == 'hostname_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_cdn_key") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_cdn_key_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_cdn_key") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetCdnKeyRequest.pb(video_stitcher_service.GetCdnKeyRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = cdn_keys.CdnKey.to_json(cdn_keys.CdnKey()) + req.return_value.content = return_value + + request = video_stitcher_service.GetCdnKeyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = cdn_keys.CdnKey() + post_with_metadata.return_value = cdn_keys.CdnKey(), metadata + + client.get_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_cdn_key_rest_bad_request(request_type=video_stitcher_service.DeleteCdnKeyRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_cdn_key(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteCdnKeyRequest, + dict, +]) +def test_delete_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_cdn_key(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_cdn_key") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_cdn_key_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_cdn_key") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteCdnKeyRequest.pb(video_stitcher_service.DeleteCdnKeyRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.DeleteCdnKeyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_cdn_key_rest_bad_request(request_type=video_stitcher_service.UpdateCdnKeyRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'cdn_key': {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_cdn_key(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateCdnKeyRequest, + dict, +]) +def test_update_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'cdn_key': {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'}} + request_init["cdn_key"] = {'google_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value'}, 'akamai_cdn_key': {'token_key': b'token_key_blob'}, 'media_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value', 'token_config': {'query_parameter': 'query_parameter_value'}}, 'name': 'projects/sample1/locations/sample2/cdnKeys/sample3', 'hostname': 'hostname_value'} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateCdnKeyRequest.meta.fields["cdn_key"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["cdn_key"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["cdn_key"][field])): + del request_init["cdn_key"][field][i][subfield] + else: + del request_init["cdn_key"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_cdn_key(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_cdn_key") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_cdn_key_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_cdn_key") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateCdnKeyRequest.pb(video_stitcher_service.UpdateCdnKeyRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.UpdateCdnKeyRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_vod_session_rest_bad_request(request_type=video_stitcher_service.CreateVodSessionRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_vod_session(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateVodSessionRequest, + dict, +]) +def test_create_vod_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["vod_session"] = {'name': 'name_value', 'interstitials': {'ad_breaks': [{'progress_events': [{'time_offset': {'seconds': 751, 'nanos': 543}, 'events': [{'type_': 1, 'uri': 'uri_value', 'id': 'id_value', 'offset': {}}]}], 'ads': [{'duration': {}, 'companion_ads': {'display_requirement': 1, 'companions': [{'iframe_ad_resource': {'uri': 'uri_value'}, 'static_ad_resource': {'uri': 'uri_value', 'creative_type': 'creative_type_value'}, 'html_ad_resource': {'html_source': 'html_source_value'}, 'api_framework': 'api_framework_value', 'height_px': 960, 'width_px': 871, 'asset_height_px': 1599, 'expanded_height_px': 1896, 'asset_width_px': 1510, 'expanded_width_px': 1807, 'ad_slot_id': 'ad_slot_id_value', 'events': {}}]}, 'activity_events': {}}], 'end_time_offset': {}, 'start_time_offset': {}}], 'session_content': {'duration': {}}}, 'play_uri': 'play_uri_value', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'ad_tag_macro_map': {}, 'manifest_options': {'include_renditions': [{'bitrate_bps': 1167, 'codecs': 'codecs_value'}], 'bitrate_order': 1}, 'asset_id': 'asset_id_value', 'ad_tracking': 1, 'gam_settings': {'network_code': 'network_code_value', 'stream_id': 'stream_id_value'}, 'vod_config': 'vod_config_value'} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateVodSessionRequest.meta.fields["vod_session"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["vod_session"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vod_session"][field])): + del request_init["vod_session"][field][i][subfield] + else: + del request_init["vod_session"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_vod_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.asset_id == 'asset_id_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == 'vod_config_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_vod_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_session") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_session_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_vod_session") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateVodSessionRequest.pb(video_stitcher_service.CreateVodSessionRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.VodSession.to_json(sessions.VodSession()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateVodSessionRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.VodSession() + post_with_metadata.return_value = sessions.VodSession(), metadata + + client.create_vod_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_vod_session_rest_bad_request(request_type=video_stitcher_service.GetVodSessionRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_session(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodSessionRequest, + dict, +]) +def test_get_vod_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession( + name='name_value', + play_uri='play_uri_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + asset_id='asset_id_value', + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config='vod_config_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.asset_id == 'asset_id_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == 'vod_config_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_session") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_session_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_session") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodSessionRequest.pb(video_stitcher_service.GetVodSessionRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.VodSession.to_json(sessions.VodSession()) + req.return_value.content = return_value + + request = video_stitcher_service.GetVodSessionRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.VodSession() + post_with_metadata.return_value = sessions.VodSession(), metadata + + client.get_vod_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_vod_stitch_details_rest_bad_request(request_type=video_stitcher_service.ListVodStitchDetailsRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_vod_stitch_details(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListVodStitchDetailsRequest, + dict, +]) +def test_list_vod_stitch_details_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodStitchDetailsResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_vod_stitch_details(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodStitchDetailsPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_vod_stitch_details_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_stitch_details") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_stitch_details_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_stitch_details") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListVodStitchDetailsRequest.pb(video_stitcher_service.ListVodStitchDetailsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListVodStitchDetailsResponse.to_json(video_stitcher_service.ListVodStitchDetailsResponse()) + req.return_value.content = return_value + + request = video_stitcher_service.ListVodStitchDetailsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListVodStitchDetailsResponse() + post_with_metadata.return_value = video_stitcher_service.ListVodStitchDetailsResponse(), metadata + + client.list_vod_stitch_details(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_vod_stitch_detail_rest_bad_request(request_type=video_stitcher_service.GetVodStitchDetailRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_stitch_detail(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodStitchDetailRequest, + dict, +]) +def test_get_vod_stitch_detail_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = stitch_details.VodStitchDetail( + name='name_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = stitch_details.VodStitchDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_stitch_detail(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, stitch_details.VodStitchDetail) + assert response.name == 'name_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_stitch_detail_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_stitch_detail") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_stitch_detail_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_stitch_detail") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodStitchDetailRequest.pb(video_stitcher_service.GetVodStitchDetailRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = stitch_details.VodStitchDetail.to_json(stitch_details.VodStitchDetail()) + req.return_value.content = return_value + + request = video_stitcher_service.GetVodStitchDetailRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = stitch_details.VodStitchDetail() + post_with_metadata.return_value = stitch_details.VodStitchDetail(), metadata + + client.get_vod_stitch_detail(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_vod_ad_tag_details_rest_bad_request(request_type=video_stitcher_service.ListVodAdTagDetailsRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_vod_ad_tag_details(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListVodAdTagDetailsRequest, + dict, +]) +def test_list_vod_ad_tag_details_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodAdTagDetailsResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_vod_ad_tag_details(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodAdTagDetailsPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_vod_ad_tag_details_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_ad_tag_details") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_ad_tag_details_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_ad_tag_details") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListVodAdTagDetailsRequest.pb(video_stitcher_service.ListVodAdTagDetailsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.to_json(video_stitcher_service.ListVodAdTagDetailsResponse()) + req.return_value.content = return_value + + request = video_stitcher_service.ListVodAdTagDetailsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + post_with_metadata.return_value = video_stitcher_service.ListVodAdTagDetailsResponse(), metadata + + client.list_vod_ad_tag_details(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_vod_ad_tag_detail_rest_bad_request(request_type=video_stitcher_service.GetVodAdTagDetailRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_ad_tag_detail(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodAdTagDetailRequest, + dict, +]) +def test_get_vod_ad_tag_detail_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.VodAdTagDetail( + name='name_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.VodAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_ad_tag_detail(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.VodAdTagDetail) + assert response.name == 'name_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_ad_tag_detail_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_ad_tag_detail") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_ad_tag_detail_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_ad_tag_detail") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodAdTagDetailRequest.pb(video_stitcher_service.GetVodAdTagDetailRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = ad_tag_details.VodAdTagDetail.to_json(ad_tag_details.VodAdTagDetail()) + req.return_value.content = return_value + + request = video_stitcher_service.GetVodAdTagDetailRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = ad_tag_details.VodAdTagDetail() + post_with_metadata.return_value = ad_tag_details.VodAdTagDetail(), metadata + + client.get_vod_ad_tag_detail(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_live_ad_tag_details_rest_bad_request(request_type=video_stitcher_service.ListLiveAdTagDetailsRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_live_ad_tag_details(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListLiveAdTagDetailsRequest, + dict, +]) +def test_list_live_ad_tag_details_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_live_ad_tag_details(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveAdTagDetailsPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_live_ad_tag_details_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_ad_tag_details") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_ad_tag_details_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_live_ad_tag_details") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListLiveAdTagDetailsRequest.pb(video_stitcher_service.ListLiveAdTagDetailsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.to_json(video_stitcher_service.ListLiveAdTagDetailsResponse()) + req.return_value.content = return_value + + request = video_stitcher_service.ListLiveAdTagDetailsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + post_with_metadata.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse(), metadata + + client.list_live_ad_tag_details(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_live_ad_tag_detail_rest_bad_request(request_type=video_stitcher_service.GetLiveAdTagDetailRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_live_ad_tag_detail(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetLiveAdTagDetailRequest, + dict, +]) +def test_get_live_ad_tag_detail_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.LiveAdTagDetail( + name='name_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_live_ad_tag_detail(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.LiveAdTagDetail) + assert response.name == 'name_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_live_ad_tag_detail_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_ad_tag_detail") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_ad_tag_detail_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_live_ad_tag_detail") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetLiveAdTagDetailRequest.pb(video_stitcher_service.GetLiveAdTagDetailRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = ad_tag_details.LiveAdTagDetail.to_json(ad_tag_details.LiveAdTagDetail()) + req.return_value.content = return_value + + request = video_stitcher_service.GetLiveAdTagDetailRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = ad_tag_details.LiveAdTagDetail() + post_with_metadata.return_value = ad_tag_details.LiveAdTagDetail(), metadata + + client.get_live_ad_tag_detail(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_slate_rest_bad_request(request_type=video_stitcher_service.CreateSlateRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_slate(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateSlateRequest, + dict, +]) +def test_create_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["slate"] = {'name': 'name_value', 'uri': 'uri_value', 'gam_slate': {'network_code': 'network_code_value', 'gam_slate_id': 1241}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateSlateRequest.meta.fields["slate"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["slate"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["slate"][field])): + del request_init["slate"][field][i][subfield] + else: + del request_init["slate"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_slate(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_slate") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_slate_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_slate") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateSlateRequest.pb(video_stitcher_service.CreateSlateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateSlateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_slates_rest_bad_request(request_type=video_stitcher_service.ListSlatesRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_slates(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListSlatesRequest, + dict, +]) +def test_list_slates_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListSlatesResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_slates(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSlatesPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_slates_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_slates") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_slates_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_slates") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListSlatesRequest.pb(video_stitcher_service.ListSlatesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListSlatesResponse.to_json(video_stitcher_service.ListSlatesResponse()) + req.return_value.content = return_value + + request = video_stitcher_service.ListSlatesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListSlatesResponse() + post_with_metadata.return_value = video_stitcher_service.ListSlatesResponse(), metadata + + client.list_slates(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_slate_rest_bad_request(request_type=video_stitcher_service.GetSlateRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_slate(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetSlateRequest, + dict, +]) +def test_get_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = slates.Slate( + name='name_value', + uri='uri_value', + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = slates.Slate.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_slate(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, slates.Slate) + assert response.name == 'name_value' + assert response.uri == 'uri_value' + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_slate") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_slate_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_slate") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetSlateRequest.pb(video_stitcher_service.GetSlateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = slates.Slate.to_json(slates.Slate()) + req.return_value.content = return_value + + request = video_stitcher_service.GetSlateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = slates.Slate() + post_with_metadata.return_value = slates.Slate(), metadata + + client.get_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_slate_rest_bad_request(request_type=video_stitcher_service.UpdateSlateRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'slate': {'name': 'projects/sample1/locations/sample2/slates/sample3'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_slate(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateSlateRequest, + dict, +]) +def test_update_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'slate': {'name': 'projects/sample1/locations/sample2/slates/sample3'}} + request_init["slate"] = {'name': 'projects/sample1/locations/sample2/slates/sample3', 'uri': 'uri_value', 'gam_slate': {'network_code': 'network_code_value', 'gam_slate_id': 1241}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateSlateRequest.meta.fields["slate"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["slate"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["slate"][field])): + del request_init["slate"][field][i][subfield] + else: + del request_init["slate"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_slate(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_slate") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_slate_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_slate") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateSlateRequest.pb(video_stitcher_service.UpdateSlateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.UpdateSlateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_slate_rest_bad_request(request_type=video_stitcher_service.DeleteSlateRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_slate(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteSlateRequest, + dict, +]) +def test_delete_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_slate(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_slate") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_slate_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_slate") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteSlateRequest.pb(video_stitcher_service.DeleteSlateRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.DeleteSlateRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_live_session_rest_bad_request(request_type=video_stitcher_service.CreateLiveSessionRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_live_session(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateLiveSessionRequest, + dict, +]) +def test_create_live_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["live_session"] = {'name': 'name_value', 'play_uri': 'play_uri_value', 'ad_tag_macros': {}, 'manifest_options': {'include_renditions': [{'bitrate_bps': 1167, 'codecs': 'codecs_value'}], 'bitrate_order': 1}, 'gam_settings': {'stream_id': 'stream_id_value', 'targeting_parameters': {}}, 'live_config': 'live_config_value', 'ad_tracking': 1} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateLiveSessionRequest.meta.fields["live_session"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["live_session"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["live_session"][field])): + del request_init["live_session"][field][i][subfield] + else: + del request_init["live_session"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_live_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.live_config == 'live_config_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_live_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_session") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_session_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_live_session") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateLiveSessionRequest.pb(video_stitcher_service.CreateLiveSessionRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.LiveSession.to_json(sessions.LiveSession()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateLiveSessionRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.LiveSession() + post_with_metadata.return_value = sessions.LiveSession(), metadata + + client.create_live_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_live_session_rest_bad_request(request_type=video_stitcher_service.GetLiveSessionRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_live_session(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetLiveSessionRequest, + dict, +]) +def test_get_live_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession( + name='name_value', + play_uri='play_uri_value', + live_config='live_config_value', + ad_tracking=live_configs.AdTracking.CLIENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_live_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == 'name_value' + assert response.play_uri == 'play_uri_value' + assert response.live_config == 'live_config_value' + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_live_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_session") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_session_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_live_session") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetLiveSessionRequest.pb(video_stitcher_service.GetLiveSessionRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.LiveSession.to_json(sessions.LiveSession()) + req.return_value.content = return_value + + request = video_stitcher_service.GetLiveSessionRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.LiveSession() + post_with_metadata.return_value = sessions.LiveSession(), metadata + + client.get_live_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_live_config_rest_bad_request(request_type=video_stitcher_service.CreateLiveConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_live_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateLiveConfigRequest, + dict, +]) +def test_create_live_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["live_config"] = {'name': 'name_value', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_live_config': {'network_code': 'network_code_value', 'asset_key': 'asset_key_value', 'custom_asset_key': 'custom_asset_key_value'}, 'state': 1, 'ad_tracking': 1, 'default_slate': 'default_slate_value', 'stitching_policy': 1, 'prefetch_config': {'enabled': True, 'initial_ad_request_duration': {'seconds': 751, 'nanos': 543}}, 'source_fetch_options': {'headers': {}}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateLiveConfigRequest.meta.fields["live_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["live_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["live_config"][field])): + del request_init["live_config"][field][i][subfield] + else: + del request_init["live_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_live_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_live_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateLiveConfigRequest.pb(video_stitcher_service.CreateLiveConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateLiveConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_live_configs_rest_bad_request(request_type=video_stitcher_service.ListLiveConfigsRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_live_configs(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListLiveConfigsRequest, + dict, +]) +def test_list_live_configs_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_live_configs(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_live_configs_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_configs") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_configs_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_live_configs") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListLiveConfigsRequest.pb(video_stitcher_service.ListLiveConfigsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListLiveConfigsResponse.to_json(video_stitcher_service.ListLiveConfigsResponse()) + req.return_value.content = return_value + + request = video_stitcher_service.ListLiveConfigsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListLiveConfigsResponse() + post_with_metadata.return_value = video_stitcher_service.ListLiveConfigsResponse(), metadata + + client.list_live_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_live_config_rest_bad_request(request_type=video_stitcher_service.GetLiveConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_live_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetLiveConfigRequest, + dict, +]) +def test_get_live_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = live_configs.LiveConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=live_configs.LiveConfig.State.CREATING, + ad_tracking=live_configs.AdTracking.CLIENT, + default_slate='default_slate_value', + stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = live_configs.LiveConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_live_config(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, live_configs.LiveConfig) + assert response.name == 'name_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.state == live_configs.LiveConfig.State.CREATING + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.default_slate == 'default_slate_value' + assert response.stitching_policy == live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_live_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetLiveConfigRequest.pb(video_stitcher_service.GetLiveConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = live_configs.LiveConfig.to_json(live_configs.LiveConfig()) + req.return_value.content = return_value + + request = video_stitcher_service.GetLiveConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = live_configs.LiveConfig() + post_with_metadata.return_value = live_configs.LiveConfig(), metadata + + client.get_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_live_config_rest_bad_request(request_type=video_stitcher_service.DeleteLiveConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_live_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteLiveConfigRequest, + dict, +]) +def test_delete_live_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_live_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_live_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_live_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_live_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteLiveConfigRequest.pb(video_stitcher_service.DeleteLiveConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.DeleteLiveConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_live_config_rest_bad_request(request_type=video_stitcher_service.UpdateLiveConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'live_config': {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_live_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateLiveConfigRequest, + dict, +]) +def test_update_live_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'live_config': {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'}} + request_init["live_config"] = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_live_config': {'network_code': 'network_code_value', 'asset_key': 'asset_key_value', 'custom_asset_key': 'custom_asset_key_value'}, 'state': 1, 'ad_tracking': 1, 'default_slate': 'default_slate_value', 'stitching_policy': 1, 'prefetch_config': {'enabled': True, 'initial_ad_request_duration': {'seconds': 751, 'nanos': 543}}, 'source_fetch_options': {'headers': {}}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateLiveConfigRequest.meta.fields["live_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["live_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["live_config"][field])): + del request_init["live_config"][field][i][subfield] + else: + del request_init["live_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_live_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_live_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_live_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_live_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateLiveConfigRequest.pb(video_stitcher_service.UpdateLiveConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.UpdateLiveConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_vod_config_rest_bad_request(request_type=video_stitcher_service.CreateVodConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_vod_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.CreateVodConfigRequest, + dict, +]) +def test_create_vod_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["vod_config"] = {'name': 'name_value', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_vod_config': {'network_code': 'network_code_value'}, 'state': 1, 'source_fetch_options': {'headers': {}}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateVodConfigRequest.meta.fields["vod_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["vod_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vod_config"][field])): + del request_init["vod_config"][field][i][subfield] + else: + del request_init["vod_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_vod_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_vod_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateVodConfigRequest.pb(video_stitcher_service.CreateVodConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateVodConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_vod_configs_rest_bad_request(request_type=video_stitcher_service.ListVodConfigsRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_vod_configs(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.ListVodConfigsRequest, + dict, +]) +def test_list_vod_configs_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodConfigsResponse( + next_page_token='next_page_token_value', + unreachable=['unreachable_value'], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_vod_configs(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodConfigsPager) + assert response.next_page_token == 'next_page_token_value' + assert response.unreachable == ['unreachable_value'] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_vod_configs_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_configs") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_configs_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_configs") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListVodConfigsRequest.pb(video_stitcher_service.ListVodConfigsRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListVodConfigsResponse.to_json(video_stitcher_service.ListVodConfigsResponse()) + req.return_value.content = return_value + + request = video_stitcher_service.ListVodConfigsRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListVodConfigsResponse() + post_with_metadata.return_value = video_stitcher_service.ListVodConfigsResponse(), metadata + + client.list_vod_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_vod_config_rest_bad_request(request_type=video_stitcher_service.GetVodConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.GetVodConfigRequest, + dict, +]) +def test_get_vod_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = vod_configs.VodConfig( + name='name_value', + source_uri='source_uri_value', + ad_tag_uri='ad_tag_uri_value', + state=vod_configs.VodConfig.State.CREATING, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = vod_configs.VodConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_config(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, vod_configs.VodConfig) + assert response.name == 'name_value' + assert response.source_uri == 'source_uri_value' + assert response.ad_tag_uri == 'ad_tag_uri_value' + assert response.state == vod_configs.VodConfig.State.CREATING + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodConfigRequest.pb(video_stitcher_service.GetVodConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = vod_configs.VodConfig.to_json(vod_configs.VodConfig()) + req.return_value.content = return_value + + request = video_stitcher_service.GetVodConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = vod_configs.VodConfig() + post_with_metadata.return_value = vod_configs.VodConfig(), metadata + + client.get_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_vod_config_rest_bad_request(request_type=video_stitcher_service.DeleteVodConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_vod_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.DeleteVodConfigRequest, + dict, +]) +def test_delete_vod_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_vod_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_vod_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_vod_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_vod_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteVodConfigRequest.pb(video_stitcher_service.DeleteVodConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.DeleteVodConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_vod_config_rest_bad_request(request_type=video_stitcher_service.UpdateVodConfigRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {'vod_config': {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_vod_config(request) + + +@pytest.mark.parametrize("request_type", [ + video_stitcher_service.UpdateVodConfigRequest, + dict, +]) +def test_update_vod_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {'vod_config': {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'}} + request_init["vod_config"] = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_vod_config': {'network_code': 'network_code_value'}, 'state': 1, 'source_fetch_options': {'headers': {}}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateVodConfigRequest.meta.fields["vod_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["vod_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vod_config"][field])): + del request_init["vod_config"][field][i][subfield] + else: + del request_init["vod_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name='operations/spam') + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_vod_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(operation.Operation, "_set_result_from_operation"), \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_vod_config") as post, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_vod_config_with_metadata") as post_with_metadata, \ + mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_vod_config") as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateVodConfigRequest.pb(video_stitcher_service.UpdateVodConfigRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.UpdateVodConfigRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_cancel_operation_rest_bad_request(request_type=operations_pb2.CancelOperationRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.cancel_operation(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.CancelOperationRequest, + dict, +]) +def test_cancel_operation_rest(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = '{}' + response_value.content = json_return_value.encode('UTF-8') + + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.cancel_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_operation_rest_bad_request(request_type=operations_pb2.DeleteOperationRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_operation(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.DeleteOperationRequest, + dict, +]) +def test_delete_operation_rest(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = '{}' + response_value.content = json_return_value.encode('UTF-8') + + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_operation(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_get_operation_rest_bad_request(request_type=operations_pb2.GetOperationRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_operation(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.GetOperationRequest, + dict, +]) +def test_get_operation_rest(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_operation(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_list_operations_rest_bad_request(request_type=operations_pb2.ListOperationsRequest): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = '' + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_operations(request) + + +@pytest.mark.parametrize("request_type", [ + operations_pb2.ListOperationsRequest, + dict, +]) +def test_list_operations_rest(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + request_init = {'name': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.ListOperationsResponse() + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode('UTF-8') + + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_operations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + +def test_initialize_client_w_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_cdn_key), + '__call__') as call: + client.create_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_cdn_keys_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_cdn_keys), + '__call__') as call: + client.list_cdn_keys(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListCdnKeysRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_cdn_key), + '__call__') as call: + client.get_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_cdn_key), + '__call__') as call: + client.delete_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_cdn_key), + '__call__') as call: + client.update_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_vod_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), + '__call__') as call: + client.create_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_session), + '__call__') as call: + client.get_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_stitch_details_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), + '__call__') as call: + client.list_vod_stitch_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodStitchDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_stitch_detail_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), + '__call__') as call: + client.get_vod_stitch_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodStitchDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_ad_tag_details_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), + '__call__') as call: + client.list_vod_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_ad_tag_detail_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), + '__call__') as call: + client.get_vod_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_live_ad_tag_details_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), + '__call__') as call: + client.list_live_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_ad_tag_detail_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), + '__call__') as call: + client.get_live_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_slate), + '__call__') as call: + client.create_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_slates_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_slates), + '__call__') as call: + client.list_slates(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListSlatesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_slate), + '__call__') as call: + client.get_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_slate), + '__call__') as call: + client.update_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_slate), + '__call__') as call: + client.delete_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_live_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), + '__call__') as call: + client.create_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_session), + '__call__') as call: + client.get_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), + '__call__') as call: + client.create_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_live_configs_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), + '__call__') as call: + client.list_live_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_config), + '__call__') as call: + client.get_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), + '__call__') as call: + client.delete_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), + '__call__') as call: + client.update_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), + '__call__') as call: + client.create_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_configs_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_configs), + '__call__') as call: + client.list_vod_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_config), + '__call__') as call: + client.get_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), + '__call__') as call: + client.delete_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), + '__call__') as call: + client.update_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateVodConfigRequest() + + assert args[0] == request_msg + + +def test_video_stitcher_service_rest_lro_client(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + transport = client.transport + + # Ensure that we have an api-core operations client. + assert isinstance( + transport.operations_client, +operations_v1.AbstractOperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.VideoStitcherServiceGrpcTransport, + ) + +def test_video_stitcher_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.VideoStitcherServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_video_stitcher_service_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.VideoStitcherServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'create_cdn_key', + 'list_cdn_keys', + 'get_cdn_key', + 'delete_cdn_key', + 'update_cdn_key', + 'create_vod_session', + 'get_vod_session', + 'list_vod_stitch_details', + 'get_vod_stitch_detail', + 'list_vod_ad_tag_details', + 'get_vod_ad_tag_detail', + 'list_live_ad_tag_details', + 'get_live_ad_tag_detail', + 'create_slate', + 'list_slates', + 'get_slate', + 'update_slate', + 'delete_slate', + 'create_live_session', + 'get_live_session', + 'create_live_config', + 'list_live_configs', + 'get_live_config', + 'delete_live_config', + 'update_live_config', + 'create_vod_config', + 'list_vod_configs', + 'get_vod_config', + 'delete_vod_config', + 'update_vod_config', + 'get_operation', + 'cancel_operation', + 'delete_operation', + 'list_operations', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Additionally, the LRO client (a property) should + # also raise NotImplementedError + with pytest.raises(NotImplementedError): + transport.operations_client + + # Catch all for all remaining methods and properties + remainder = [ + 'kind', + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_video_stitcher_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.VideoStitcherServiceTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +def test_video_stitcher_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.VideoStitcherServiceTransport() + adc.assert_called_once() + + +def test_video_stitcher_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + VideoStitcherServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VideoStitcherServiceGrpcTransport, + transports.VideoStitcherServiceGrpcAsyncIOTransport, + ], +) +def test_video_stitcher_service_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VideoStitcherServiceGrpcTransport, + transports.VideoStitcherServiceGrpcAsyncIOTransport, + transports.VideoStitcherServiceRestTransport, + ], +) +def test_video_stitcher_service_transport_auth_gdch_credentials(transport_class): + host = 'https://language.com' + api_audience_tests = [None, 'https://language2.com'] + api_audience_expect = [host, 'https://language2.com'] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with( + e + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.VideoStitcherServiceGrpcTransport, grpc_helpers), + (transports.VideoStitcherServiceGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_video_stitcher_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "videostitcher.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="videostitcher.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.VideoStitcherServiceGrpcTransport, transports.VideoStitcherServiceGrpcAsyncIOTransport]) +def test_video_stitcher_service_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + +def test_video_stitcher_service_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: + transports.VideoStitcherServiceRestTransport ( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_video_stitcher_service_host_no_port(transport_name): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='videostitcher.googleapis.com'), + transport=transport_name, + ) + assert client.transport._host == ( + 'videostitcher.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://videostitcher.googleapis.com' + ) + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_video_stitcher_service_host_with_port(transport_name): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='videostitcher.googleapis.com:8000'), + transport=transport_name, + ) + assert client.transport._host == ( + 'videostitcher.googleapis.com:8000' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://videostitcher.googleapis.com:8000' + ) + +@pytest.mark.parametrize("transport_name", [ + "rest", +]) +def test_video_stitcher_service_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = VideoStitcherServiceClient( + credentials=creds1, + transport=transport_name, + ) + client2 = VideoStitcherServiceClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.create_cdn_key._session + session2 = client2.transport.create_cdn_key._session + assert session1 != session2 + session1 = client1.transport.list_cdn_keys._session + session2 = client2.transport.list_cdn_keys._session + assert session1 != session2 + session1 = client1.transport.get_cdn_key._session + session2 = client2.transport.get_cdn_key._session + assert session1 != session2 + session1 = client1.transport.delete_cdn_key._session + session2 = client2.transport.delete_cdn_key._session + assert session1 != session2 + session1 = client1.transport.update_cdn_key._session + session2 = client2.transport.update_cdn_key._session + assert session1 != session2 + session1 = client1.transport.create_vod_session._session + session2 = client2.transport.create_vod_session._session + assert session1 != session2 + session1 = client1.transport.get_vod_session._session + session2 = client2.transport.get_vod_session._session + assert session1 != session2 + session1 = client1.transport.list_vod_stitch_details._session + session2 = client2.transport.list_vod_stitch_details._session + assert session1 != session2 + session1 = client1.transport.get_vod_stitch_detail._session + session2 = client2.transport.get_vod_stitch_detail._session + assert session1 != session2 + session1 = client1.transport.list_vod_ad_tag_details._session + session2 = client2.transport.list_vod_ad_tag_details._session + assert session1 != session2 + session1 = client1.transport.get_vod_ad_tag_detail._session + session2 = client2.transport.get_vod_ad_tag_detail._session + assert session1 != session2 + session1 = client1.transport.list_live_ad_tag_details._session + session2 = client2.transport.list_live_ad_tag_details._session + assert session1 != session2 + session1 = client1.transport.get_live_ad_tag_detail._session + session2 = client2.transport.get_live_ad_tag_detail._session + assert session1 != session2 + session1 = client1.transport.create_slate._session + session2 = client2.transport.create_slate._session + assert session1 != session2 + session1 = client1.transport.list_slates._session + session2 = client2.transport.list_slates._session + assert session1 != session2 + session1 = client1.transport.get_slate._session + session2 = client2.transport.get_slate._session + assert session1 != session2 + session1 = client1.transport.update_slate._session + session2 = client2.transport.update_slate._session + assert session1 != session2 + session1 = client1.transport.delete_slate._session + session2 = client2.transport.delete_slate._session + assert session1 != session2 + session1 = client1.transport.create_live_session._session + session2 = client2.transport.create_live_session._session + assert session1 != session2 + session1 = client1.transport.get_live_session._session + session2 = client2.transport.get_live_session._session + assert session1 != session2 + session1 = client1.transport.create_live_config._session + session2 = client2.transport.create_live_config._session + assert session1 != session2 + session1 = client1.transport.list_live_configs._session + session2 = client2.transport.list_live_configs._session + assert session1 != session2 + session1 = client1.transport.get_live_config._session + session2 = client2.transport.get_live_config._session + assert session1 != session2 + session1 = client1.transport.delete_live_config._session + session2 = client2.transport.delete_live_config._session + assert session1 != session2 + session1 = client1.transport.update_live_config._session + session2 = client2.transport.update_live_config._session + assert session1 != session2 + session1 = client1.transport.create_vod_config._session + session2 = client2.transport.create_vod_config._session + assert session1 != session2 + session1 = client1.transport.list_vod_configs._session + session2 = client2.transport.list_vod_configs._session + assert session1 != session2 + session1 = client1.transport.get_vod_config._session + session2 = client2.transport.get_vod_config._session + assert session1 != session2 + session1 = client1.transport.delete_vod_config._session + session2 = client2.transport.delete_vod_config._session + assert session1 != session2 + session1 = client1.transport.update_vod_config._session + session2 = client2.transport.update_vod_config._session + assert session1 != session2 +def test_video_stitcher_service_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.VideoStitcherServiceGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_video_stitcher_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.VideoStitcherServiceGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.VideoStitcherServiceGrpcTransport, transports.VideoStitcherServiceGrpcAsyncIOTransport]) +def test_video_stitcher_service_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.VideoStitcherServiceGrpcTransport, transports.VideoStitcherServiceGrpcAsyncIOTransport]) +def test_video_stitcher_service_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_video_stitcher_service_grpc_lro_client(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_video_stitcher_service_grpc_lro_async_client(): + client = VideoStitcherServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='grpc_asyncio', + ) + transport = client.transport + + # Ensure that we have a api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + +def test_cdn_key_path(): + project = "squid" + location = "clam" + cdn_key = "whelk" + expected = "projects/{project}/locations/{location}/cdnKeys/{cdn_key}".format(project=project, location=location, cdn_key=cdn_key, ) + actual = VideoStitcherServiceClient.cdn_key_path(project, location, cdn_key) + assert expected == actual + + +def test_parse_cdn_key_path(): + expected = { + "project": "octopus", + "location": "oyster", + "cdn_key": "nudibranch", + } + path = VideoStitcherServiceClient.cdn_key_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_cdn_key_path(path) + assert expected == actual + +def test_live_ad_tag_detail_path(): + project = "cuttlefish" + location = "mussel" + live_session = "winkle" + live_ad_tag_detail = "nautilus" + expected = "projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}".format(project=project, location=location, live_session=live_session, live_ad_tag_detail=live_ad_tag_detail, ) + actual = VideoStitcherServiceClient.live_ad_tag_detail_path(project, location, live_session, live_ad_tag_detail) + assert expected == actual + + +def test_parse_live_ad_tag_detail_path(): + expected = { + "project": "scallop", + "location": "abalone", + "live_session": "squid", + "live_ad_tag_detail": "clam", + } + path = VideoStitcherServiceClient.live_ad_tag_detail_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_live_ad_tag_detail_path(path) + assert expected == actual + +def test_live_config_path(): + project = "whelk" + location = "octopus" + live_config = "oyster" + expected = "projects/{project}/locations/{location}/liveConfigs/{live_config}".format(project=project, location=location, live_config=live_config, ) + actual = VideoStitcherServiceClient.live_config_path(project, location, live_config) + assert expected == actual + + +def test_parse_live_config_path(): + expected = { + "project": "nudibranch", + "location": "cuttlefish", + "live_config": "mussel", + } + path = VideoStitcherServiceClient.live_config_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_live_config_path(path) + assert expected == actual + +def test_live_session_path(): + project = "winkle" + location = "nautilus" + live_session = "scallop" + expected = "projects/{project}/locations/{location}/liveSessions/{live_session}".format(project=project, location=location, live_session=live_session, ) + actual = VideoStitcherServiceClient.live_session_path(project, location, live_session) + assert expected == actual + + +def test_parse_live_session_path(): + expected = { + "project": "abalone", + "location": "squid", + "live_session": "clam", + } + path = VideoStitcherServiceClient.live_session_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_live_session_path(path) + assert expected == actual + +def test_slate_path(): + project = "whelk" + location = "octopus" + slate = "oyster" + expected = "projects/{project}/locations/{location}/slates/{slate}".format(project=project, location=location, slate=slate, ) + actual = VideoStitcherServiceClient.slate_path(project, location, slate) + assert expected == actual + + +def test_parse_slate_path(): + expected = { + "project": "nudibranch", + "location": "cuttlefish", + "slate": "mussel", + } + path = VideoStitcherServiceClient.slate_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_slate_path(path) + assert expected == actual + +def test_vod_ad_tag_detail_path(): + project = "winkle" + location = "nautilus" + vod_session = "scallop" + vod_ad_tag_detail = "abalone" + expected = "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodAdTagDetails/{vod_ad_tag_detail}".format(project=project, location=location, vod_session=vod_session, vod_ad_tag_detail=vod_ad_tag_detail, ) + actual = VideoStitcherServiceClient.vod_ad_tag_detail_path(project, location, vod_session, vod_ad_tag_detail) + assert expected == actual + + +def test_parse_vod_ad_tag_detail_path(): + expected = { + "project": "squid", + "location": "clam", + "vod_session": "whelk", + "vod_ad_tag_detail": "octopus", + } + path = VideoStitcherServiceClient.vod_ad_tag_detail_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_vod_ad_tag_detail_path(path) + assert expected == actual + +def test_vod_config_path(): + project = "oyster" + location = "nudibranch" + vod_config = "cuttlefish" + expected = "projects/{project}/locations/{location}/vodConfigs/{vod_config}".format(project=project, location=location, vod_config=vod_config, ) + actual = VideoStitcherServiceClient.vod_config_path(project, location, vod_config) + assert expected == actual + + +def test_parse_vod_config_path(): + expected = { + "project": "mussel", + "location": "winkle", + "vod_config": "nautilus", + } + path = VideoStitcherServiceClient.vod_config_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_vod_config_path(path) + assert expected == actual + +def test_vod_session_path(): + project = "scallop" + location = "abalone" + vod_session = "squid" + expected = "projects/{project}/locations/{location}/vodSessions/{vod_session}".format(project=project, location=location, vod_session=vod_session, ) + actual = VideoStitcherServiceClient.vod_session_path(project, location, vod_session) + assert expected == actual + + +def test_parse_vod_session_path(): + expected = { + "project": "clam", + "location": "whelk", + "vod_session": "octopus", + } + path = VideoStitcherServiceClient.vod_session_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_vod_session_path(path) + assert expected == actual + +def test_vod_stitch_detail_path(): + project = "oyster" + location = "nudibranch" + vod_session = "cuttlefish" + vod_stitch_detail = "mussel" + expected = "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodStitchDetails/{vod_stitch_detail}".format(project=project, location=location, vod_session=vod_session, vod_stitch_detail=vod_stitch_detail, ) + actual = VideoStitcherServiceClient.vod_stitch_detail_path(project, location, vod_session, vod_stitch_detail) + assert expected == actual + + +def test_parse_vod_stitch_detail_path(): + expected = { + "project": "winkle", + "location": "nautilus", + "vod_session": "scallop", + "vod_stitch_detail": "abalone", + } + path = VideoStitcherServiceClient.vod_stitch_detail_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_vod_stitch_detail_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "squid" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = VideoStitcherServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "clam", + } + path = VideoStitcherServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "whelk" + expected = "folders/{folder}".format(folder=folder, ) + actual = VideoStitcherServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "octopus", + } + path = VideoStitcherServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "oyster" + expected = "organizations/{organization}".format(organization=organization, ) + actual = VideoStitcherServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nudibranch", + } + path = VideoStitcherServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "cuttlefish" + expected = "projects/{project}".format(project=project, ) + actual = VideoStitcherServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "mussel", + } + path = VideoStitcherServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "winkle" + location = "nautilus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = VideoStitcherServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "scallop", + "location": "abalone", + } + path = VideoStitcherServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = VideoStitcherServiceClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_with_default_client_info(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.VideoStitcherServiceTransport, '_prep_wrapped_messages') as prep: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.VideoStitcherServiceTransport, '_prep_wrapped_messages') as prep: + transport_class = VideoStitcherServiceClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + +def test_delete_operation(transport: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.DeleteOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None +@pytest.mark.asyncio +async def test_delete_operation_async(transport: str = "grpc_asyncio"): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.DeleteOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.delete_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + +def test_delete_operation_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.DeleteOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + call.return_value = None + + client.delete_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_delete_operation_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.DeleteOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + await client.delete_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] + +def test_delete_operation_from_dict(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.delete_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_delete_operation_from_dict_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.delete_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_cancel_operation(transport: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None +@pytest.mark.asyncio +async def test_cancel_operation_async(transport: str = "grpc_asyncio"): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.CancelOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert response is None + +def test_cancel_operation_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = None + + client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_cancel_operation_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.CancelOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + await client.cancel_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] + +def test_cancel_operation_from_dict(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = None + + response = client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_cancel_operation_from_dict_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + None + ) + response = await client.cancel_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_get_operation(transport: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + response = client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) +@pytest.mark.asyncio +async def test_get_operation_async(transport: str = "grpc_asyncio"): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.GetOperationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + +def test_get_operation_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = operations_pb2.Operation() + + client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_get_operation_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.GetOperationRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + await client.get_operation(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] + +def test_get_operation_from_dict(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.Operation() + + response = client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_get_operation_from_dict_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_operation), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation() + ) + response = await client.get_operation( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_list_operations(transport: str = "grpc"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + response = client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) +@pytest.mark.asyncio +async def test_list_operations_async(transport: str = "grpc_asyncio"): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = operations_pb2.ListOperationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) + +def test_list_operations_field_headers(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = operations_pb2.ListOperationsResponse() + + client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_list_operations_field_headers_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = operations_pb2.ListOperationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + await client.list_operations(request) + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "name=locations",) in kw["metadata"] + +def test_list_operations_from_dict(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = operations_pb2.ListOperationsResponse() + + response = client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_list_operations_from_dict_async(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_operations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.ListOperationsResponse() + ) + response = await client.list_operations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_transport_close_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc" + ) + with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +@pytest.mark.asyncio +async def test_transport_close_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio" + ) + with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest" + ) + with mock.patch.object(type(getattr(client.transport, "_session")), "close") as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + 'rest', + 'grpc', + ] + for transport in transports: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() + +@pytest.mark.parametrize("client_class,transport_class", [ + (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport), + (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport), +]) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) From c0407742a3fa0dcb2230a1024e1fe70b2457493d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 30 Sep 2025 00:03:26 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../v1/.coveragerc | 13 - .../google-cloud-video-stitcher/v1/.flake8 | 34 - .../google-cloud-video-stitcher/v1/LICENSE | 202 - .../v1/MANIFEST.in | 20 - .../google-cloud-video-stitcher/v1/README.rst | 143 - .../v1/docs/_static/custom.css | 20 - .../v1/docs/_templates/layout.html | 50 - .../v1/docs/conf.py | 385 - .../v1/docs/index.rst | 10 - .../v1/docs/multiprocessing.rst | 7 - .../v1/docs/stitcher_v1/services_.rst | 6 - .../v1/docs/stitcher_v1/types_.rst | 6 - .../stitcher_v1/video_stitcher_service.rst | 10 - .../google/cloud/video/stitcher/__init__.py | 171 - .../cloud/video/stitcher/gapic_version.py | 16 - .../v1/google/cloud/video/stitcher/py.typed | 2 - .../cloud/video/stitcher_v1/__init__.py | 172 - .../video/stitcher_v1/gapic_metadata.json | 478 - .../cloud/video/stitcher_v1/gapic_version.py | 16 - .../google/cloud/video/stitcher_v1/py.typed | 2 - .../video/stitcher_v1/services/__init__.py | 15 - .../video_stitcher_service/__init__.py | 22 - .../video_stitcher_service/async_client.py | 4240 --- .../services/video_stitcher_service/client.py | 4651 --- .../services/video_stitcher_service/pagers.py | 1006 - .../transports/README.rst | 9 - .../transports/__init__.py | 38 - .../video_stitcher_service/transports/base.py | 635 - .../video_stitcher_service/transports/grpc.py | 1222 - .../transports/grpc_asyncio.py | 1408 - .../video_stitcher_service/transports/rest.py | 6004 ---- .../cloud/video/stitcher_v1/types/__init__.py | 184 - .../video/stitcher_v1/types/ad_tag_details.py | 180 - .../cloud/video/stitcher_v1/types/cdn_keys.py | 182 - .../video/stitcher_v1/types/companions.py | 240 - .../cloud/video/stitcher_v1/types/events.py | 177 - .../video/stitcher_v1/types/fetch_options.py | 50 - .../video/stitcher_v1/types/live_configs.py | 236 - .../cloud/video/stitcher_v1/types/sessions.py | 452 - .../cloud/video/stitcher_v1/types/slates.py | 83 - .../video/stitcher_v1/types/stitch_details.py | 106 - .../types/video_stitcher_service.py | 1124 - .../video/stitcher_v1/types/vod_configs.py | 118 - .../google-cloud-video-stitcher/v1/mypy.ini | 3 - .../google-cloud-video-stitcher/v1/noxfile.py | 591 - ...tadata_google.cloud.video.stitcher.v1.json | 4957 --- ...o_stitcher_service_create_cdn_key_async.py | 57 - ...eo_stitcher_service_create_cdn_key_sync.py | 57 - ...itcher_service_create_live_config_async.py | 62 - ...titcher_service_create_live_config_sync.py | 62 - ...tcher_service_create_live_session_async.py | 56 - ...itcher_service_create_live_session_sync.py | 56 - ...deo_stitcher_service_create_slate_async.py | 57 - ...ideo_stitcher_service_create_slate_sync.py | 57 - ...titcher_service_create_vod_config_async.py | 62 - ...stitcher_service_create_vod_config_sync.py | 62 - ...itcher_service_create_vod_session_async.py | 56 - ...titcher_service_create_vod_session_sync.py | 56 - ...o_stitcher_service_delete_cdn_key_async.py | 56 - ...eo_stitcher_service_delete_cdn_key_sync.py | 56 - ...itcher_service_delete_live_config_async.py | 56 - ...titcher_service_delete_live_config_sync.py | 56 - ...deo_stitcher_service_delete_slate_async.py | 56 - ...ideo_stitcher_service_delete_slate_sync.py | 56 - ...titcher_service_delete_vod_config_async.py | 56 - ...stitcher_service_delete_vod_config_sync.py | 56 - ...ideo_stitcher_service_get_cdn_key_async.py | 52 - ...video_stitcher_service_get_cdn_key_sync.py | 52 - ...er_service_get_live_ad_tag_detail_async.py | 52 - ...her_service_get_live_ad_tag_detail_sync.py | 52 - ..._stitcher_service_get_live_config_async.py | 52 - ...o_stitcher_service_get_live_config_sync.py | 52 - ...stitcher_service_get_live_session_async.py | 52 - ..._stitcher_service_get_live_session_sync.py | 52 - ..._video_stitcher_service_get_slate_async.py | 52 - ...d_video_stitcher_service_get_slate_sync.py | 52 - ...her_service_get_vod_ad_tag_detail_async.py | 52 - ...cher_service_get_vod_ad_tag_detail_sync.py | 52 - ...o_stitcher_service_get_vod_config_async.py | 52 - ...eo_stitcher_service_get_vod_config_sync.py | 52 - ..._stitcher_service_get_vod_session_async.py | 52 - ...o_stitcher_service_get_vod_session_sync.py | 52 - ...her_service_get_vod_stitch_detail_async.py | 52 - ...cher_service_get_vod_stitch_detail_sync.py | 52 - ...eo_stitcher_service_list_cdn_keys_async.py | 53 - ...deo_stitcher_service_list_cdn_keys_sync.py | 53 - ..._service_list_live_ad_tag_details_async.py | 53 - ...r_service_list_live_ad_tag_details_sync.py | 53 - ...titcher_service_list_live_configs_async.py | 53 - ...stitcher_service_list_live_configs_sync.py | 53 - ...ideo_stitcher_service_list_slates_async.py | 53 - ...video_stitcher_service_list_slates_sync.py | 53 - ...r_service_list_vod_ad_tag_details_async.py | 53 - ...er_service_list_vod_ad_tag_details_sync.py | 53 - ...stitcher_service_list_vod_configs_async.py | 53 - ..._stitcher_service_list_vod_configs_sync.py | 53 - ...r_service_list_vod_stitch_details_async.py | 53 - ...er_service_list_vod_stitch_details_sync.py | 53 - ...o_stitcher_service_update_cdn_key_async.py | 55 - ...eo_stitcher_service_update_cdn_key_sync.py | 55 - ...itcher_service_update_live_config_async.py | 60 - ...titcher_service_update_live_config_sync.py | 60 - ...deo_stitcher_service_update_slate_async.py | 55 - ...ideo_stitcher_service_update_slate_sync.py | 55 - ...titcher_service_update_vod_config_async.py | 60 - ...stitcher_service_update_vod_config_sync.py | 60 - .../v1/scripts/fixup_stitcher_v1_keywords.py | 205 - .../google-cloud-video-stitcher/v1/setup.py | 98 - .../v1/testing/constraints-3.10.txt | 6 - .../v1/testing/constraints-3.11.txt | 6 - .../v1/testing/constraints-3.12.txt | 6 - .../v1/testing/constraints-3.13.txt | 11 - .../v1/testing/constraints-3.7.txt | 10 - .../v1/testing/constraints-3.8.txt | 6 - .../v1/testing/constraints-3.9.txt | 6 - .../v1/tests/__init__.py | 16 - .../v1/tests/unit/__init__.py | 16 - .../v1/tests/unit/gapic/__init__.py | 16 - .../tests/unit/gapic/stitcher_v1/__init__.py | 16 - .../test_video_stitcher_service.py | 25166 ---------------- .../video/stitcher_v1/gapic_metadata.json | 155 + .../services/video_stitcher_service/client.py | 2 + .../transports/__init__.py | 4 + .../video_stitcher_service/transports/rest.py | 7228 ++++- .../transports/rest_base.py | 1215 +- .../test_video_stitcher_service.py | 13929 ++++++++- 126 files changed, 19876 insertions(+), 61223 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/README.rst delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/setup.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py rename {owl-bot-staging/google-cloud-video-stitcher/v1 => packages/google-cloud-video-stitcher}/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py (51%) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc b/owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc deleted file mode 100644 index d8fd2d427e9a..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/video/stitcher/__init__.py - google/cloud/video/stitcher/gapic_version.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 b/owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 deleted file mode 100644 index 90316de21489..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/.flake8 +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -[flake8] -# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): -# Resolve flake8 lint issues -ignore = E203, E231, E266, E501, W503 -exclude = - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): - # Ensure that generated code passes flake8 lint - **/gapic/** - **/services/** - **/types/** - # Exclude Protobuf gencode - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE b/owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE deleted file mode 100644 index d64569567334..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in b/owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in deleted file mode 100644 index dae249ec8976..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/MANIFEST.in +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -include README.rst LICENSE -recursive-include google *.py *.pyi *.json *.proto py.typed -recursive-include tests * -global-exclude *.py[co] -global-exclude __pycache__ diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/README.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/README.rst deleted file mode 100644 index bc5dade72671..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/README.rst +++ /dev/null @@ -1,143 +0,0 @@ -Python Client for Google Cloud Video Stitcher 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 Video Stitcher 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 - - -Logging -------- - -This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes. -Note the following: - -#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging. -#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**. -#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below. - - -Simple, environment-based configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google -logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged -messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging -event. - -A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log. - -- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc. -- Invalid logging scopes: :code:`foo`, :code:`123`, etc. - -**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers. - - -Examples -^^^^^^^^ - -- Enabling the default handler for all Google-based loggers - -.. code-block:: console - - export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google - -- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`): - -.. code-block:: console - - export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1 - - -Advanced, code-based configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can also configure a valid logging scope using Python's standard `logging` mechanism. - - -Examples -^^^^^^^^ - -- Configuring a handler for all Google-based loggers - -.. code-block:: python - - import logging - - from google.cloud.translate_v3 import translate - - base_logger = logging.getLogger("google") - base_logger.addHandler(logging.StreamHandler()) - base_logger.setLevel(logging.DEBUG) - -- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`): - -.. code-block:: python - - import logging - - from google.cloud.translate_v3 import translate - - base_logger = logging.getLogger("google.cloud.library_v1") - base_logger.addHandler(logging.StreamHandler()) - base_logger.setLevel(logging.DEBUG) - - -Logging details -~~~~~~~~~~~~~~~ - -#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root - logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set - :code:`logging.getLogger("google").propagate = True` in your code. -#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for - one library, but decide you need to also set up environment-based logging configuration for another library. - - #. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual - if the code -based configuration gets applied first. - -#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get - executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured. - (This is the reason for 2.i. above.) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css deleted file mode 100644 index b0a295464b23..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_static/custom.css +++ /dev/null @@ -1,20 +0,0 @@ -div#python2-eol { - border-color: red; - border-width: medium; -} - -/* Ensure minimum width for 'Parameters' / 'Returns' column */ -dl.field-list > dt { - min-width: 100px -} - -/* Insert space between methods for readability */ -dl.method { - padding-top: 10px; - padding-bottom: 10px -} - -/* Insert empty space between classes */ -dl.class { - padding-bottom: 50px -} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html deleted file mode 100644 index 95e9c77fcfe1..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/_templates/layout.html +++ /dev/null @@ -1,50 +0,0 @@ - -{% extends "!layout.html" %} -{%- block content %} -{%- if theme_fixed_sidebar|lower == 'true' %} -
- {{ sidebar() }} - {%- block document %} -
- {%- if render_sidebar %} -
- {%- endif %} - - {%- block relbar_top %} - {%- if theme_show_relbar_top|tobool %} - - {%- endif %} - {% endblock %} - -
-
- As of January 1, 2020 this library no longer supports Python 2 on the latest released version. - Library versions released prior to that date will continue to be available. For more information please - visit Python 2 support on Google Cloud. -
- {% block body %} {% endblock %} -
- - {%- block relbar_bottom %} - {%- if theme_show_relbar_bottom|tobool %} - - {%- endif %} - {% endblock %} - - {%- if render_sidebar %} -
- {%- endif %} -
- {%- endblock %} -
-
-{%- else %} -{{ super() }} -{%- endif %} -{%- endblock %} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py deleted file mode 100644 index eaab15dec8d1..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/conf.py +++ /dev/null @@ -1,385 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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-video-stitcher 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("..")) - -# For plugins that can not read conf.py. -# See also: https://github.com/docascode/sphinx-docfx-yaml/issues/85 -sys.path.insert(0, os.path.abspath(".")) - -__version__ = "" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "4.5.0" - -# 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.doctest", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", - "recommonmark", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_options = {"members": True} -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# source_suffix = ['.rst', '.md'] -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-video-stitcher" -copyright = u"2025, Google, LLC" -author = u"Google APIs" - -# 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", - "**/.nox/**/*", - "samples/AUTHORING_GUIDE.md", - "samples/CONTRIBUTING.md", - "samples/snippets/README.rst", -] - -# 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 Video Client Libraries for google-cloud-video-stitcher", - "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-video-stitcher-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-video-stitcher.tex", - u"google-cloud-video-stitcher 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-video-stitcher", - "google-cloud-video-stitcher 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-video-stitcher", - "google-cloud-video-stitcher Documentation", - author, - "google-cloud-video-stitcher", - "google-cloud-video-stitcher Library", - "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": ("https://python.readthedocs.org/en/latest/", None), - "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ( - "https://googleapis.dev/python/google-api-core/latest/", - None, - ), - "grpc": ("https://grpc.github.io/grpc/python/", None), - "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst deleted file mode 100644 index ed4637468133..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/index.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. include:: multiprocessing.rst - - -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - stitcher_v1/services_ - stitcher_v1/types_ diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst deleted file mode 100644 index 536d17b2ea65..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/multiprocessing.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. note:: - - Because this client uses :mod:`grpc` library, it is safe to - share instances across threads. In multiprocessing scenarios, the best - practice is to create client instances *after* the invocation of - :func:`os.fork` by :class:`multiprocessing.pool.Pool` or - :class:`multiprocessing.Process`. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst deleted file mode 100644 index 413e5a0db521..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/services_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Video Stitcher v1 API -=============================================== -.. toctree:: - :maxdepth: 2 - - video_stitcher_service diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst deleted file mode 100644 index 3d8d2580c1c3..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/types_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Video Stitcher v1 API -============================================ - -.. automodule:: google.cloud.video.stitcher_v1.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst deleted file mode 100644 index 5052a0d9045f..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/docs/stitcher_v1/video_stitcher_service.rst +++ /dev/null @@ -1,10 +0,0 @@ -VideoStitcherService --------------------------------------- - -.. automodule:: google.cloud.video.stitcher_v1.services.video_stitcher_service - :members: - :inherited-members: - -.. automodule:: google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py deleted file mode 100644 index e739eb58f275..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/__init__.py +++ /dev/null @@ -1,171 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.video.stitcher_v1.services.video_stitcher_service.client import VideoStitcherServiceClient -from google.cloud.video.stitcher_v1.services.video_stitcher_service.async_client import VideoStitcherServiceAsyncClient - -from google.cloud.video.stitcher_v1.types.ad_tag_details import AdRequest -from google.cloud.video.stitcher_v1.types.ad_tag_details import LiveAdTagDetail -from google.cloud.video.stitcher_v1.types.ad_tag_details import RequestMetadata -from google.cloud.video.stitcher_v1.types.ad_tag_details import ResponseMetadata -from google.cloud.video.stitcher_v1.types.ad_tag_details import VodAdTagDetail -from google.cloud.video.stitcher_v1.types.cdn_keys import AkamaiCdnKey -from google.cloud.video.stitcher_v1.types.cdn_keys import CdnKey -from google.cloud.video.stitcher_v1.types.cdn_keys import GoogleCdnKey -from google.cloud.video.stitcher_v1.types.cdn_keys import MediaCdnKey -from google.cloud.video.stitcher_v1.types.companions import Companion -from google.cloud.video.stitcher_v1.types.companions import CompanionAds -from google.cloud.video.stitcher_v1.types.companions import HtmlAdResource -from google.cloud.video.stitcher_v1.types.companions import IframeAdResource -from google.cloud.video.stitcher_v1.types.companions import StaticAdResource -from google.cloud.video.stitcher_v1.types.events import Event -from google.cloud.video.stitcher_v1.types.events import ProgressEvent -from google.cloud.video.stitcher_v1.types.fetch_options import FetchOptions -from google.cloud.video.stitcher_v1.types.live_configs import GamLiveConfig -from google.cloud.video.stitcher_v1.types.live_configs import LiveConfig -from google.cloud.video.stitcher_v1.types.live_configs import PrefetchConfig -from google.cloud.video.stitcher_v1.types.live_configs import AdTracking -from google.cloud.video.stitcher_v1.types.sessions import Interstitials -from google.cloud.video.stitcher_v1.types.sessions import LiveSession -from google.cloud.video.stitcher_v1.types.sessions import ManifestOptions -from google.cloud.video.stitcher_v1.types.sessions import RenditionFilter -from google.cloud.video.stitcher_v1.types.sessions import VodSession -from google.cloud.video.stitcher_v1.types.sessions import VodSessionAd -from google.cloud.video.stitcher_v1.types.sessions import VodSessionAdBreak -from google.cloud.video.stitcher_v1.types.sessions import VodSessionContent -from google.cloud.video.stitcher_v1.types.slates import Slate -from google.cloud.video.stitcher_v1.types.stitch_details import AdStitchDetail -from google.cloud.video.stitcher_v1.types.stitch_details import VodStitchDetail -from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateCdnKeyRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateLiveConfigRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateLiveSessionRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateSlateRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateVodConfigRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import CreateVodSessionRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteCdnKeyRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteLiveConfigRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteSlateRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import DeleteVodConfigRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetCdnKeyRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetLiveAdTagDetailRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetLiveConfigRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetLiveSessionRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetSlateRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodAdTagDetailRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodConfigRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodSessionRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import GetVodStitchDetailRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListCdnKeysRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListCdnKeysResponse -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveAdTagDetailsRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveAdTagDetailsResponse -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveConfigsRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListLiveConfigsResponse -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListSlatesRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListSlatesResponse -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodAdTagDetailsRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodAdTagDetailsResponse -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodConfigsRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodConfigsResponse -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodStitchDetailsRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import ListVodStitchDetailsResponse -from google.cloud.video.stitcher_v1.types.video_stitcher_service import OperationMetadata -from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateCdnKeyRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateLiveConfigRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateSlateRequest -from google.cloud.video.stitcher_v1.types.video_stitcher_service import UpdateVodConfigRequest -from google.cloud.video.stitcher_v1.types.vod_configs import GamVodConfig -from google.cloud.video.stitcher_v1.types.vod_configs import VodConfig - -__all__ = ('VideoStitcherServiceClient', - 'VideoStitcherServiceAsyncClient', - 'AdRequest', - 'LiveAdTagDetail', - 'RequestMetadata', - 'ResponseMetadata', - 'VodAdTagDetail', - 'AkamaiCdnKey', - 'CdnKey', - 'GoogleCdnKey', - 'MediaCdnKey', - 'Companion', - 'CompanionAds', - 'HtmlAdResource', - 'IframeAdResource', - 'StaticAdResource', - 'Event', - 'ProgressEvent', - 'FetchOptions', - 'GamLiveConfig', - 'LiveConfig', - 'PrefetchConfig', - 'AdTracking', - 'Interstitials', - 'LiveSession', - 'ManifestOptions', - 'RenditionFilter', - 'VodSession', - 'VodSessionAd', - 'VodSessionAdBreak', - 'VodSessionContent', - 'Slate', - 'AdStitchDetail', - 'VodStitchDetail', - 'CreateCdnKeyRequest', - 'CreateLiveConfigRequest', - 'CreateLiveSessionRequest', - 'CreateSlateRequest', - 'CreateVodConfigRequest', - 'CreateVodSessionRequest', - 'DeleteCdnKeyRequest', - 'DeleteLiveConfigRequest', - 'DeleteSlateRequest', - 'DeleteVodConfigRequest', - 'GetCdnKeyRequest', - 'GetLiveAdTagDetailRequest', - 'GetLiveConfigRequest', - 'GetLiveSessionRequest', - 'GetSlateRequest', - 'GetVodAdTagDetailRequest', - 'GetVodConfigRequest', - 'GetVodSessionRequest', - 'GetVodStitchDetailRequest', - 'ListCdnKeysRequest', - 'ListCdnKeysResponse', - 'ListLiveAdTagDetailsRequest', - 'ListLiveAdTagDetailsResponse', - 'ListLiveConfigsRequest', - 'ListLiveConfigsResponse', - 'ListSlatesRequest', - 'ListSlatesResponse', - 'ListVodAdTagDetailsRequest', - 'ListVodAdTagDetailsResponse', - 'ListVodConfigsRequest', - 'ListVodConfigsResponse', - 'ListVodStitchDetailsRequest', - 'ListVodStitchDetailsResponse', - 'OperationMetadata', - 'UpdateCdnKeyRequest', - 'UpdateLiveConfigRequest', - 'UpdateSlateRequest', - 'UpdateVodConfigRequest', - 'GamVodConfig', - 'VodConfig', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py deleted file mode 100644 index 20a9cd975b02..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed deleted file mode 100644 index 158ff5acbd28..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-video-stitcher package uses inline types. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py deleted file mode 100644 index 228e190e0885..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/__init__.py +++ /dev/null @@ -1,172 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher_v1 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.video_stitcher_service import VideoStitcherServiceClient -from .services.video_stitcher_service import VideoStitcherServiceAsyncClient - -from .types.ad_tag_details import AdRequest -from .types.ad_tag_details import LiveAdTagDetail -from .types.ad_tag_details import RequestMetadata -from .types.ad_tag_details import ResponseMetadata -from .types.ad_tag_details import VodAdTagDetail -from .types.cdn_keys import AkamaiCdnKey -from .types.cdn_keys import CdnKey -from .types.cdn_keys import GoogleCdnKey -from .types.cdn_keys import MediaCdnKey -from .types.companions import Companion -from .types.companions import CompanionAds -from .types.companions import HtmlAdResource -from .types.companions import IframeAdResource -from .types.companions import StaticAdResource -from .types.events import Event -from .types.events import ProgressEvent -from .types.fetch_options import FetchOptions -from .types.live_configs import GamLiveConfig -from .types.live_configs import LiveConfig -from .types.live_configs import PrefetchConfig -from .types.live_configs import AdTracking -from .types.sessions import Interstitials -from .types.sessions import LiveSession -from .types.sessions import ManifestOptions -from .types.sessions import RenditionFilter -from .types.sessions import VodSession -from .types.sessions import VodSessionAd -from .types.sessions import VodSessionAdBreak -from .types.sessions import VodSessionContent -from .types.slates import Slate -from .types.stitch_details import AdStitchDetail -from .types.stitch_details import VodStitchDetail -from .types.video_stitcher_service import CreateCdnKeyRequest -from .types.video_stitcher_service import CreateLiveConfigRequest -from .types.video_stitcher_service import CreateLiveSessionRequest -from .types.video_stitcher_service import CreateSlateRequest -from .types.video_stitcher_service import CreateVodConfigRequest -from .types.video_stitcher_service import CreateVodSessionRequest -from .types.video_stitcher_service import DeleteCdnKeyRequest -from .types.video_stitcher_service import DeleteLiveConfigRequest -from .types.video_stitcher_service import DeleteSlateRequest -from .types.video_stitcher_service import DeleteVodConfigRequest -from .types.video_stitcher_service import GetCdnKeyRequest -from .types.video_stitcher_service import GetLiveAdTagDetailRequest -from .types.video_stitcher_service import GetLiveConfigRequest -from .types.video_stitcher_service import GetLiveSessionRequest -from .types.video_stitcher_service import GetSlateRequest -from .types.video_stitcher_service import GetVodAdTagDetailRequest -from .types.video_stitcher_service import GetVodConfigRequest -from .types.video_stitcher_service import GetVodSessionRequest -from .types.video_stitcher_service import GetVodStitchDetailRequest -from .types.video_stitcher_service import ListCdnKeysRequest -from .types.video_stitcher_service import ListCdnKeysResponse -from .types.video_stitcher_service import ListLiveAdTagDetailsRequest -from .types.video_stitcher_service import ListLiveAdTagDetailsResponse -from .types.video_stitcher_service import ListLiveConfigsRequest -from .types.video_stitcher_service import ListLiveConfigsResponse -from .types.video_stitcher_service import ListSlatesRequest -from .types.video_stitcher_service import ListSlatesResponse -from .types.video_stitcher_service import ListVodAdTagDetailsRequest -from .types.video_stitcher_service import ListVodAdTagDetailsResponse -from .types.video_stitcher_service import ListVodConfigsRequest -from .types.video_stitcher_service import ListVodConfigsResponse -from .types.video_stitcher_service import ListVodStitchDetailsRequest -from .types.video_stitcher_service import ListVodStitchDetailsResponse -from .types.video_stitcher_service import OperationMetadata -from .types.video_stitcher_service import UpdateCdnKeyRequest -from .types.video_stitcher_service import UpdateLiveConfigRequest -from .types.video_stitcher_service import UpdateSlateRequest -from .types.video_stitcher_service import UpdateVodConfigRequest -from .types.vod_configs import GamVodConfig -from .types.vod_configs import VodConfig - -__all__ = ( - 'VideoStitcherServiceAsyncClient', -'AdRequest', -'AdStitchDetail', -'AdTracking', -'AkamaiCdnKey', -'CdnKey', -'Companion', -'CompanionAds', -'CreateCdnKeyRequest', -'CreateLiveConfigRequest', -'CreateLiveSessionRequest', -'CreateSlateRequest', -'CreateVodConfigRequest', -'CreateVodSessionRequest', -'DeleteCdnKeyRequest', -'DeleteLiveConfigRequest', -'DeleteSlateRequest', -'DeleteVodConfigRequest', -'Event', -'FetchOptions', -'GamLiveConfig', -'GamVodConfig', -'GetCdnKeyRequest', -'GetLiveAdTagDetailRequest', -'GetLiveConfigRequest', -'GetLiveSessionRequest', -'GetSlateRequest', -'GetVodAdTagDetailRequest', -'GetVodConfigRequest', -'GetVodSessionRequest', -'GetVodStitchDetailRequest', -'GoogleCdnKey', -'HtmlAdResource', -'IframeAdResource', -'Interstitials', -'ListCdnKeysRequest', -'ListCdnKeysResponse', -'ListLiveAdTagDetailsRequest', -'ListLiveAdTagDetailsResponse', -'ListLiveConfigsRequest', -'ListLiveConfigsResponse', -'ListSlatesRequest', -'ListSlatesResponse', -'ListVodAdTagDetailsRequest', -'ListVodAdTagDetailsResponse', -'ListVodConfigsRequest', -'ListVodConfigsResponse', -'ListVodStitchDetailsRequest', -'ListVodStitchDetailsResponse', -'LiveAdTagDetail', -'LiveConfig', -'LiveSession', -'ManifestOptions', -'MediaCdnKey', -'OperationMetadata', -'PrefetchConfig', -'ProgressEvent', -'RenditionFilter', -'RequestMetadata', -'ResponseMetadata', -'Slate', -'StaticAdResource', -'UpdateCdnKeyRequest', -'UpdateLiveConfigRequest', -'UpdateSlateRequest', -'UpdateVodConfigRequest', -'VideoStitcherServiceClient', -'VodAdTagDetail', -'VodConfig', -'VodSession', -'VodSessionAd', -'VodSessionAdBreak', -'VodSessionContent', -'VodStitchDetail', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json deleted file mode 100644 index 92a8e4a173a8..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_metadata.json +++ /dev/null @@ -1,478 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.video.stitcher_v1", - "protoPackage": "google.cloud.video.stitcher.v1", - "schema": "1.0", - "services": { - "VideoStitcherService": { - "clients": { - "grpc": { - "libraryClient": "VideoStitcherServiceClient", - "rpcs": { - "CreateCdnKey": { - "methods": [ - "create_cdn_key" - ] - }, - "CreateLiveConfig": { - "methods": [ - "create_live_config" - ] - }, - "CreateLiveSession": { - "methods": [ - "create_live_session" - ] - }, - "CreateSlate": { - "methods": [ - "create_slate" - ] - }, - "CreateVodConfig": { - "methods": [ - "create_vod_config" - ] - }, - "CreateVodSession": { - "methods": [ - "create_vod_session" - ] - }, - "DeleteCdnKey": { - "methods": [ - "delete_cdn_key" - ] - }, - "DeleteLiveConfig": { - "methods": [ - "delete_live_config" - ] - }, - "DeleteSlate": { - "methods": [ - "delete_slate" - ] - }, - "DeleteVodConfig": { - "methods": [ - "delete_vod_config" - ] - }, - "GetCdnKey": { - "methods": [ - "get_cdn_key" - ] - }, - "GetLiveAdTagDetail": { - "methods": [ - "get_live_ad_tag_detail" - ] - }, - "GetLiveConfig": { - "methods": [ - "get_live_config" - ] - }, - "GetLiveSession": { - "methods": [ - "get_live_session" - ] - }, - "GetSlate": { - "methods": [ - "get_slate" - ] - }, - "GetVodAdTagDetail": { - "methods": [ - "get_vod_ad_tag_detail" - ] - }, - "GetVodConfig": { - "methods": [ - "get_vod_config" - ] - }, - "GetVodSession": { - "methods": [ - "get_vod_session" - ] - }, - "GetVodStitchDetail": { - "methods": [ - "get_vod_stitch_detail" - ] - }, - "ListCdnKeys": { - "methods": [ - "list_cdn_keys" - ] - }, - "ListLiveAdTagDetails": { - "methods": [ - "list_live_ad_tag_details" - ] - }, - "ListLiveConfigs": { - "methods": [ - "list_live_configs" - ] - }, - "ListSlates": { - "methods": [ - "list_slates" - ] - }, - "ListVodAdTagDetails": { - "methods": [ - "list_vod_ad_tag_details" - ] - }, - "ListVodConfigs": { - "methods": [ - "list_vod_configs" - ] - }, - "ListVodStitchDetails": { - "methods": [ - "list_vod_stitch_details" - ] - }, - "UpdateCdnKey": { - "methods": [ - "update_cdn_key" - ] - }, - "UpdateLiveConfig": { - "methods": [ - "update_live_config" - ] - }, - "UpdateSlate": { - "methods": [ - "update_slate" - ] - }, - "UpdateVodConfig": { - "methods": [ - "update_vod_config" - ] - } - } - }, - "grpc-async": { - "libraryClient": "VideoStitcherServiceAsyncClient", - "rpcs": { - "CreateCdnKey": { - "methods": [ - "create_cdn_key" - ] - }, - "CreateLiveConfig": { - "methods": [ - "create_live_config" - ] - }, - "CreateLiveSession": { - "methods": [ - "create_live_session" - ] - }, - "CreateSlate": { - "methods": [ - "create_slate" - ] - }, - "CreateVodConfig": { - "methods": [ - "create_vod_config" - ] - }, - "CreateVodSession": { - "methods": [ - "create_vod_session" - ] - }, - "DeleteCdnKey": { - "methods": [ - "delete_cdn_key" - ] - }, - "DeleteLiveConfig": { - "methods": [ - "delete_live_config" - ] - }, - "DeleteSlate": { - "methods": [ - "delete_slate" - ] - }, - "DeleteVodConfig": { - "methods": [ - "delete_vod_config" - ] - }, - "GetCdnKey": { - "methods": [ - "get_cdn_key" - ] - }, - "GetLiveAdTagDetail": { - "methods": [ - "get_live_ad_tag_detail" - ] - }, - "GetLiveConfig": { - "methods": [ - "get_live_config" - ] - }, - "GetLiveSession": { - "methods": [ - "get_live_session" - ] - }, - "GetSlate": { - "methods": [ - "get_slate" - ] - }, - "GetVodAdTagDetail": { - "methods": [ - "get_vod_ad_tag_detail" - ] - }, - "GetVodConfig": { - "methods": [ - "get_vod_config" - ] - }, - "GetVodSession": { - "methods": [ - "get_vod_session" - ] - }, - "GetVodStitchDetail": { - "methods": [ - "get_vod_stitch_detail" - ] - }, - "ListCdnKeys": { - "methods": [ - "list_cdn_keys" - ] - }, - "ListLiveAdTagDetails": { - "methods": [ - "list_live_ad_tag_details" - ] - }, - "ListLiveConfigs": { - "methods": [ - "list_live_configs" - ] - }, - "ListSlates": { - "methods": [ - "list_slates" - ] - }, - "ListVodAdTagDetails": { - "methods": [ - "list_vod_ad_tag_details" - ] - }, - "ListVodConfigs": { - "methods": [ - "list_vod_configs" - ] - }, - "ListVodStitchDetails": { - "methods": [ - "list_vod_stitch_details" - ] - }, - "UpdateCdnKey": { - "methods": [ - "update_cdn_key" - ] - }, - "UpdateLiveConfig": { - "methods": [ - "update_live_config" - ] - }, - "UpdateSlate": { - "methods": [ - "update_slate" - ] - }, - "UpdateVodConfig": { - "methods": [ - "update_vod_config" - ] - } - } - }, - "rest": { - "libraryClient": "VideoStitcherServiceClient", - "rpcs": { - "CreateCdnKey": { - "methods": [ - "create_cdn_key" - ] - }, - "CreateLiveConfig": { - "methods": [ - "create_live_config" - ] - }, - "CreateLiveSession": { - "methods": [ - "create_live_session" - ] - }, - "CreateSlate": { - "methods": [ - "create_slate" - ] - }, - "CreateVodConfig": { - "methods": [ - "create_vod_config" - ] - }, - "CreateVodSession": { - "methods": [ - "create_vod_session" - ] - }, - "DeleteCdnKey": { - "methods": [ - "delete_cdn_key" - ] - }, - "DeleteLiveConfig": { - "methods": [ - "delete_live_config" - ] - }, - "DeleteSlate": { - "methods": [ - "delete_slate" - ] - }, - "DeleteVodConfig": { - "methods": [ - "delete_vod_config" - ] - }, - "GetCdnKey": { - "methods": [ - "get_cdn_key" - ] - }, - "GetLiveAdTagDetail": { - "methods": [ - "get_live_ad_tag_detail" - ] - }, - "GetLiveConfig": { - "methods": [ - "get_live_config" - ] - }, - "GetLiveSession": { - "methods": [ - "get_live_session" - ] - }, - "GetSlate": { - "methods": [ - "get_slate" - ] - }, - "GetVodAdTagDetail": { - "methods": [ - "get_vod_ad_tag_detail" - ] - }, - "GetVodConfig": { - "methods": [ - "get_vod_config" - ] - }, - "GetVodSession": { - "methods": [ - "get_vod_session" - ] - }, - "GetVodStitchDetail": { - "methods": [ - "get_vod_stitch_detail" - ] - }, - "ListCdnKeys": { - "methods": [ - "list_cdn_keys" - ] - }, - "ListLiveAdTagDetails": { - "methods": [ - "list_live_ad_tag_details" - ] - }, - "ListLiveConfigs": { - "methods": [ - "list_live_configs" - ] - }, - "ListSlates": { - "methods": [ - "list_slates" - ] - }, - "ListVodAdTagDetails": { - "methods": [ - "list_vod_ad_tag_details" - ] - }, - "ListVodConfigs": { - "methods": [ - "list_vod_configs" - ] - }, - "ListVodStitchDetails": { - "methods": [ - "list_vod_stitch_details" - ] - }, - "UpdateCdnKey": { - "methods": [ - "update_cdn_key" - ] - }, - "UpdateLiveConfig": { - "methods": [ - "update_live_config" - ] - }, - "UpdateSlate": { - "methods": [ - "update_slate" - ] - }, - "UpdateVodConfig": { - "methods": [ - "update_vod_config" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py deleted file mode 100644 index 20a9cd975b02..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed deleted file mode 100644 index 158ff5acbd28..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-video-stitcher package uses inline types. diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py deleted file mode 100644 index cbf94b283c70..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py deleted file mode 100644 index 5b1e06f53a81..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 VideoStitcherServiceClient -from .async_client import VideoStitcherServiceAsyncClient - -__all__ = ( - 'VideoStitcherServiceClient', - 'VideoStitcherServiceAsyncClient', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py deleted file mode 100644 index f9d204327157..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/async_client.py +++ /dev/null @@ -1,4240 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 logging as std_logging -from collections import OrderedDict -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union - -from google.cloud.video.stitcher_v1 import gapic_version as package_version - -from google.api_core.client_options import ClientOptions -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry_async as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -import google.protobuf - - -try: - OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.video.stitcher_v1.services.video_stitcher_service import pagers -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import fetch_options -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport -from .client import VideoStitcherServiceClient - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - -class VideoStitcherServiceAsyncClient: - """Video-On-Demand content stitching API allows you to insert - ads into (VoD) video on demand files. You will be able to render - custom scrubber bars with highlighted ads, enforce ad policies, - allow seamless playback and tracking on native players and - monetize content with any standard VMAP compliant ad server. - """ - - _client: VideoStitcherServiceClient - - # Copy defaults from the synchronous client for use here. - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = VideoStitcherServiceClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT - _DEFAULT_ENDPOINT_TEMPLATE = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE - _DEFAULT_UNIVERSE = VideoStitcherServiceClient._DEFAULT_UNIVERSE - - cdn_key_path = staticmethod(VideoStitcherServiceClient.cdn_key_path) - parse_cdn_key_path = staticmethod(VideoStitcherServiceClient.parse_cdn_key_path) - live_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.live_ad_tag_detail_path) - parse_live_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.parse_live_ad_tag_detail_path) - live_config_path = staticmethod(VideoStitcherServiceClient.live_config_path) - parse_live_config_path = staticmethod(VideoStitcherServiceClient.parse_live_config_path) - live_session_path = staticmethod(VideoStitcherServiceClient.live_session_path) - parse_live_session_path = staticmethod(VideoStitcherServiceClient.parse_live_session_path) - slate_path = staticmethod(VideoStitcherServiceClient.slate_path) - parse_slate_path = staticmethod(VideoStitcherServiceClient.parse_slate_path) - vod_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.vod_ad_tag_detail_path) - parse_vod_ad_tag_detail_path = staticmethod(VideoStitcherServiceClient.parse_vod_ad_tag_detail_path) - vod_config_path = staticmethod(VideoStitcherServiceClient.vod_config_path) - parse_vod_config_path = staticmethod(VideoStitcherServiceClient.parse_vod_config_path) - vod_session_path = staticmethod(VideoStitcherServiceClient.vod_session_path) - parse_vod_session_path = staticmethod(VideoStitcherServiceClient.parse_vod_session_path) - vod_stitch_detail_path = staticmethod(VideoStitcherServiceClient.vod_stitch_detail_path) - parse_vod_stitch_detail_path = staticmethod(VideoStitcherServiceClient.parse_vod_stitch_detail_path) - common_billing_account_path = staticmethod(VideoStitcherServiceClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(VideoStitcherServiceClient.parse_common_billing_account_path) - common_folder_path = staticmethod(VideoStitcherServiceClient.common_folder_path) - parse_common_folder_path = staticmethod(VideoStitcherServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(VideoStitcherServiceClient.common_organization_path) - parse_common_organization_path = staticmethod(VideoStitcherServiceClient.parse_common_organization_path) - common_project_path = staticmethod(VideoStitcherServiceClient.common_project_path) - parse_common_project_path = staticmethod(VideoStitcherServiceClient.parse_common_project_path) - common_location_path = staticmethod(VideoStitcherServiceClient.common_location_path) - parse_common_location_path = staticmethod(VideoStitcherServiceClient.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: - VideoStitcherServiceAsyncClient: The constructed client. - """ - return VideoStitcherServiceClient.from_service_account_info.__func__(VideoStitcherServiceAsyncClient, 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: - VideoStitcherServiceAsyncClient: The constructed client. - """ - return VideoStitcherServiceClient.from_service_account_file.__func__(VideoStitcherServiceAsyncClient, 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 VideoStitcherServiceClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> VideoStitcherServiceTransport: - """Returns the transport used by the client instance. - - Returns: - VideoStitcherServiceTransport: The transport used by the client instance. - """ - return self._client.transport - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._client._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used - by the client instance. - """ - return self._client._universe_domain - - get_transport_class = VideoStitcherServiceClient.get_transport_class - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, VideoStitcherServiceTransport, Callable[..., VideoStitcherServiceTransport]]] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the video stitcher service async 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 (Optional[Union[str,VideoStitcherServiceTransport,Callable[..., VideoStitcherServiceTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport to use. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the VideoStitcherServiceTransport constructor. - 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. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "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). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS 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. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - 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. - """ - self._client = VideoStitcherServiceClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER - _LOGGER.debug( - "Created client `google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient`.", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "universeDomain": getattr(self._client._transport._credentials, "universe_domain", ""), - "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", - "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), - } if hasattr(self._client._transport, "_credentials") else { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "credentialsType": None, - } - ) - - async def create_cdn_key(self, - request: Optional[Union[video_stitcher_service.CreateCdnKeyRequest, dict]] = None, - *, - parent: Optional[str] = None, - cdn_key: Optional[cdn_keys.CdnKey] = None, - cdn_key_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a new CDN key. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_create_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateCdnKeyRequest( - parent="parent_value", - cdn_key_id="cdn_key_id_value", - ) - - # Make the request - operation = client.create_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest, dict]]): - The request object. Request message for - VideoStitcherService.createCdnKey. - parent (:class:`str`): - Required. The project in which the CDN key should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - cdn_key (:class:`google.cloud.video.stitcher_v1.types.CdnKey`): - Required. The CDN key resource to - create. - - This corresponds to the ``cdn_key`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - cdn_key_id (:class:`str`): - Required. The ID to use for the CDN - key, which will become the final - component of the CDN key's resource - name. - - This value should conform to RFC-1034, - which restricts to lower-case letters, - numbers, and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``cdn_key_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher - to sign URIs for fetching video manifests and signing - media segments for playback. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, cdn_key, cdn_key_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateCdnKeyRequest): - request = video_stitcher_service.CreateCdnKeyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if cdn_key is not None: - request.cdn_key = cdn_key - if cdn_key_id is not None: - request.cdn_key_id = cdn_key_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_cdn_key] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - cdn_keys.CdnKey, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_cdn_keys(self, - request: Optional[Union[video_stitcher_service.ListCdnKeysRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListCdnKeysAsyncPager: - r"""Lists all CDN keys in the specified project and - 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.video import stitcher_v1 - - async def sample_list_cdn_keys(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListCdnKeysRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_cdn_keys(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.ListCdnKeysRequest, dict]]): - The request object. Request message for - VideoStitcherService.listCdnKeys. - parent (:class:`str`): - Required. The project that contains the list of CDN - keys, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager: - Response message for - VideoStitcher.ListCdnKeys. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListCdnKeysRequest): - request = video_stitcher_service.ListCdnKeysRequest(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._client._transport._wrapped_methods[self._client._transport.list_cdn_keys] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListCdnKeysAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_cdn_key(self, - request: Optional[Union[video_stitcher_service.GetCdnKeyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> cdn_keys.CdnKey: - r"""Returns the specified CDN key. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_get_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetCdnKeyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_cdn_key(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetCdnKeyRequest, dict]]): - The request object. Request message for - VideoStitcherService.getCdnKey. - name (:class:`str`): - Required. The name of the CDN key to be retrieved, in - the form of - ``projects/{project}/locations/{location}/cdnKeys/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.CdnKey: - Configuration for a CDN key. Used by - the Video Stitcher to sign URIs for - fetching video manifests and signing - media segments for playback. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetCdnKeyRequest): - request = video_stitcher_service.GetCdnKeyRequest(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._client._transport._wrapped_methods[self._client._transport.get_cdn_key] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_cdn_key(self, - request: Optional[Union[video_stitcher_service.DeleteCdnKeyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes the specified CDN key. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_delete_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteCdnKeyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest, dict]]): - The request object. Request message for - VideoStitcherService.deleteCdnKey. - name (:class:`str`): - Required. The name of the CDN key to be deleted, in the - form of - ``projects/{project_number}/locations/{location}/cdnKeys/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteCdnKeyRequest): - request = video_stitcher_service.DeleteCdnKeyRequest(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._client._transport._wrapped_methods[self._client._transport.delete_cdn_key] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_cdn_key(self, - request: Optional[Union[video_stitcher_service.UpdateCdnKeyRequest, dict]] = None, - *, - cdn_key: Optional[cdn_keys.CdnKey] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the specified CDN key. Only update fields - specified in the call method body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_update_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateCdnKeyRequest( - ) - - # Make the request - operation = client.update_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest, dict]]): - The request object. Request message for - VideoStitcherService.updateCdnKey. - cdn_key (:class:`google.cloud.video.stitcher_v1.types.CdnKey`): - Required. The CDN key resource which - replaces the resource on the server. - - This corresponds to the ``cdn_key`` 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 update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher - to sign URIs for fetching video manifests and signing - media segments for playback. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [cdn_key, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateCdnKeyRequest): - request = video_stitcher_service.UpdateCdnKeyRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if cdn_key is not None: - request.cdn_key = cdn_key - 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._client._transport._wrapped_methods[self._client._transport.update_cdn_key] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("cdn_key.name", request.cdn_key.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - cdn_keys.CdnKey, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_vod_session(self, - request: Optional[Union[video_stitcher_service.CreateVodSessionRequest, dict]] = None, - *, - parent: Optional[str] = None, - vod_session: Optional[sessions.VodSession] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.VodSession: - r"""Creates a client side playback VOD session and - returns the full tracking and playback metadata of the - 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.video import stitcher_v1 - - async def sample_create_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - vod_session = stitcher_v1.VodSession() - vod_session.ad_tracking = "SERVER" - - request = stitcher_v1.CreateVodSessionRequest( - parent="parent_value", - vod_session=vod_session, - ) - - # Make the request - response = await client.create_vod_session(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateVodSessionRequest, dict]]): - The request object. Request message for - VideoStitcherService.createVodSession - parent (:class:`str`): - Required. The project and location in which the VOD - session should be created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - vod_session (:class:`google.cloud.video.stitcher_v1.types.VodSession`): - Required. Parameters for creating a - session. - - This corresponds to the ``vod_session`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodSession: - Metadata for a VOD session. The - session expires 4 hours after its - creation. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, vod_session] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateVodSessionRequest): - request = video_stitcher_service.CreateVodSessionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if vod_session is not None: - request.vod_session = vod_session - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_vod_session] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_vod_session(self, - request: Optional[Union[video_stitcher_service.GetVodSessionRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.VodSession: - r"""Returns the full tracking, playback metadata, and - relevant ad-ops logs for the specified VOD 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.video import stitcher_v1 - - async def sample_get_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodSessionRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_session(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodSessionRequest, dict]]): - The request object. Request message for - VideoStitcherService.getVodSession - name (:class:`str`): - Required. The name of the VOD session to be retrieved, - in the form of - ``projects/{project_number}/locations/{location}/vodSessions/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodSession: - Metadata for a VOD session. The - session expires 4 hours after its - creation. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodSessionRequest): - request = video_stitcher_service.GetVodSessionRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_session] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_vod_stitch_details(self, - request: Optional[Union[video_stitcher_service.ListVodStitchDetailsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVodStitchDetailsAsyncPager: - r"""Returns a list of detailed stitching information of - the specified VOD 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.video import stitcher_v1 - - async def sample_list_vod_stitch_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodStitchDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_stitch_details(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest, dict]]): - The request object. Request message for - VideoStitcherService.listVodStitchDetails. - parent (:class:`str`): - Required. The VOD session where the stitch details - belong to, in the form of - ``projects/{project}/locations/{location}/vodSessions/{id}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager: - Response message for - VideoStitcherService.listVodStitchDetails. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListVodStitchDetailsRequest): - request = video_stitcher_service.ListVodStitchDetailsRequest(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._client._transport._wrapped_methods[self._client._transport.list_vod_stitch_details] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListVodStitchDetailsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_vod_stitch_detail(self, - request: Optional[Union[video_stitcher_service.GetVodStitchDetailRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> stitch_details.VodStitchDetail: - r"""Returns the specified stitching information for the - specified VOD 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.video import stitcher_v1 - - async def sample_get_vod_stitch_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodStitchDetailRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_stitch_detail(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest, dict]]): - The request object. Request message for - VideoStitcherService.getVodStitchDetail. - name (:class:`str`): - Required. The name of the stitch detail in the specified - VOD session, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodStitchDetail: - Information related to the - interstitial of a VOD session. This - resource is only available for VOD - sessions that do not implement Google Ad - Manager ad insertion. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodStitchDetailRequest): - request = video_stitcher_service.GetVodStitchDetailRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_stitch_detail] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_vod_ad_tag_details(self, - request: Optional[Union[video_stitcher_service.ListVodAdTagDetailsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVodAdTagDetailsAsyncPager: - r"""Return the list of ad tag details for the specified - VOD 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.video import stitcher_v1 - - async def sample_list_vod_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_ad_tag_details(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest, dict]]): - The request object. Request message for - VideoStitcherService.listVodAdTagDetails. - parent (:class:`str`): - Required. The VOD session which the ad tag details - belong to, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager: - Response message for - VideoStitcherService.listVodAdTagDetails. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListVodAdTagDetailsRequest): - request = video_stitcher_service.ListVodAdTagDetailsRequest(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._client._transport._wrapped_methods[self._client._transport.list_vod_ad_tag_details] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListVodAdTagDetailsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_vod_ad_tag_detail(self, - request: Optional[Union[video_stitcher_service.GetVodAdTagDetailRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> ad_tag_details.VodAdTagDetail: - r"""Returns the specified ad tag detail for the specified - VOD 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.video import stitcher_v1 - - async def sample_get_vod_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_ad_tag_detail(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest, dict]]): - The request object. Request message for - VideoStitcherService.getVodAdTagDetail - name (:class:`str`): - Required. The name of the ad tag detail for the - specified VOD session, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{vod_ad_tag_detail}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodAdTagDetail: - Information related to the details - for one ad tag. This resource is only - available for VOD sessions that do not - implement Google Ad Manager ad - insertion. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodAdTagDetailRequest): - request = video_stitcher_service.GetVodAdTagDetailRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_ad_tag_detail] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_live_ad_tag_details(self, - request: Optional[Union[video_stitcher_service.ListLiveAdTagDetailsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListLiveAdTagDetailsAsyncPager: - r"""Return the list of ad tag details for the specified - live 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.video import stitcher_v1 - - async def sample_list_live_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_ad_tag_details(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest, dict]]): - The request object. Request message for - VideoStitcherService.listLiveAdTagDetails. - parent (:class:`str`): - Required. The resource parent in the form of - ``projects/{project}/locations/{location}/liveSessions/{live_session}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager: - Response message for - VideoStitcherService.listLiveAdTagDetails. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListLiveAdTagDetailsRequest): - request = video_stitcher_service.ListLiveAdTagDetailsRequest(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._client._transport._wrapped_methods[self._client._transport.list_live_ad_tag_details] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListLiveAdTagDetailsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_live_ad_tag_detail(self, - request: Optional[Union[video_stitcher_service.GetLiveAdTagDetailRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> ad_tag_details.LiveAdTagDetail: - r"""Returns the specified ad tag detail for the specified - live 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.video import stitcher_v1 - - async def sample_get_live_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = await client.get_live_ad_tag_detail(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest, dict]]): - The request object. Request message for - VideoStitcherService.getLiveAdTagDetail - name (:class:`str`): - Required. The resource name in the form of - ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveAdTagDetail: - Information related to the details - for one ad tag. This resource is only - available for live sessions that do not - implement Google Ad Manager ad - insertion. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetLiveAdTagDetailRequest): - request = video_stitcher_service.GetLiveAdTagDetailRequest(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._client._transport._wrapped_methods[self._client._transport.get_live_ad_tag_detail] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_slate(self, - request: Optional[Union[video_stitcher_service.CreateSlateRequest, dict]] = None, - *, - parent: Optional[str] = None, - slate: Optional[slates.Slate] = None, - slate_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Creates a slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_create_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateSlateRequest( - parent="parent_value", - slate_id="slate_id_value", - ) - - # Make the request - operation = client.create_slate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateSlateRequest, dict]]): - The request object. Request message for - VideoStitcherService.createSlate. - parent (:class:`str`): - Required. The project in which the slate should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - slate (:class:`google.cloud.video.stitcher_v1.types.Slate`): - Required. The slate to create. - This corresponds to the ``slate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - slate_id (:class:`str`): - Required. The unique identifier for - the slate. This value should conform to - RFC-1034, which restricts to lower-case - letters, numbers, and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``slate_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.Slate` - Slate object - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, slate, slate_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateSlateRequest): - request = video_stitcher_service.CreateSlateRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if slate is not None: - request.slate = slate - if slate_id is not None: - request.slate_id = slate_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_slate] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - slates.Slate, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_slates(self, - request: Optional[Union[video_stitcher_service.ListSlatesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListSlatesAsyncPager: - r"""Lists all slates in the specified project and - 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.video import stitcher_v1 - - async def sample_list_slates(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListSlatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_slates(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.ListSlatesRequest, dict]]): - The request object. Request message for - VideoStitcherService.listSlates. - parent (:class:`str`): - Required. The project to list slates, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager: - Response message for - VideoStitcherService.listSlates. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListSlatesRequest): - request = video_stitcher_service.ListSlatesRequest(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._client._transport._wrapped_methods[self._client._transport.list_slates] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListSlatesAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_slate(self, - request: Optional[Union[video_stitcher_service.GetSlateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> slates.Slate: - r"""Returns the specified slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_get_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetSlateRequest( - name="name_value", - ) - - # Make the request - response = await client.get_slate(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetSlateRequest, dict]]): - The request object. Request message for - VideoStitcherService.getSlate. - name (:class:`str`): - Required. The name of the slate to be retrieved, of the - slate, in the form of - ``projects/{project_number}/locations/{location}/slates/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.Slate: - Slate object - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetSlateRequest): - request = video_stitcher_service.GetSlateRequest(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._client._transport._wrapped_methods[self._client._transport.get_slate] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def update_slate(self, - request: Optional[Union[video_stitcher_service.UpdateSlateRequest, dict]] = None, - *, - slate: Optional[slates.Slate] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the specified slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_update_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateSlateRequest( - ) - - # Make the request - operation = client.update_slate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateSlateRequest, dict]]): - The request object. Request message for - VideoStitcherService.updateSlate. - slate (:class:`google.cloud.video.stitcher_v1.types.Slate`): - Required. The resource with updated - fields. - - This corresponds to the ``slate`` 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 update mask which - specifies fields which should 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_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.Slate` - Slate object - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [slate, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateSlateRequest): - request = video_stitcher_service.UpdateSlateRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if slate is not None: - request.slate = slate - 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._client._transport._wrapped_methods[self._client._transport.update_slate] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("slate.name", request.slate.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - slates.Slate, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def delete_slate(self, - request: Optional[Union[video_stitcher_service.DeleteSlateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes the specified slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_delete_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteSlateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_slate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteSlateRequest, dict]]): - The request object. Request message for - VideoStitcherService.deleteSlate. - name (:class:`str`): - Required. The name of the slate to be deleted, in the - form of - ``projects/{project_number}/locations/{location}/slates/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteSlateRequest): - request = video_stitcher_service.DeleteSlateRequest(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._client._transport._wrapped_methods[self._client._transport.delete_slate] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_live_session(self, - request: Optional[Union[video_stitcher_service.CreateLiveSessionRequest, dict]] = None, - *, - parent: Optional[str] = None, - live_session: Optional[sessions.LiveSession] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.LiveSession: - r"""Creates a new live 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.video import stitcher_v1 - - async def sample_create_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - live_session = stitcher_v1.LiveSession() - live_session.live_config = "live_config_value" - - request = stitcher_v1.CreateLiveSessionRequest( - parent="parent_value", - live_session=live_session, - ) - - # Make the request - response = await client.create_live_session(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest, dict]]): - The request object. Request message for - VideoStitcherService.createLiveSession. - parent (:class:`str`): - Required. The project and location in which the live - session should be created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - live_session (:class:`google.cloud.video.stitcher_v1.types.LiveSession`): - Required. Parameters for creating a - live session. - - This corresponds to the ``live_session`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveSession: - Metadata for a live session. The - session expires 5 minutes after the - client stops fetching the session's - playlists. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, live_session] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateLiveSessionRequest): - request = video_stitcher_service.CreateLiveSessionRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if live_session is not None: - request.live_session = live_session - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_live_session] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_live_session(self, - request: Optional[Union[video_stitcher_service.GetLiveSessionRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.LiveSession: - r"""Returns the details for the specified live 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.video import stitcher_v1 - - async def sample_get_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveSessionRequest( - name="name_value", - ) - - # Make the request - response = await client.get_live_session(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetLiveSessionRequest, dict]]): - The request object. Request message for - VideoStitcherService.getSession. - name (:class:`str`): - Required. The name of the live session, in the form of - ``projects/{project_number}/locations/{location}/liveSessions/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveSession: - Metadata for a live session. The - session expires 5 minutes after the - client stops fetching the session's - playlists. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetLiveSessionRequest): - request = video_stitcher_service.GetLiveSessionRequest(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._client._transport._wrapped_methods[self._client._transport.get_live_session] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def create_live_config(self, - request: Optional[Union[video_stitcher_service.CreateLiveConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - live_config: Optional[live_configs.LiveConfig] = None, - live_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Registers the live config with the provided unique ID - in the specified region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_create_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.CreateLiveConfigRequest( - parent="parent_value", - live_config_id="live_config_id_value", - live_config=live_config, - ) - - # Make the request - operation = client.create_live_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.createLiveConfig - parent (:class:`str`): - Required. The project in which the live config should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - live_config (:class:`google.cloud.video.stitcher_v1.types.LiveConfig`): - Required. The live config resource to - create. - - This corresponds to the ``live_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - live_config_id (:class:`str`): - Required. The unique identifier ID to - use for the live config. - - This corresponds to the ``live_config_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.LiveConfig` - Metadata for used to register live configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, live_config, live_config_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateLiveConfigRequest): - request = video_stitcher_service.CreateLiveConfigRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if live_config is not None: - request.live_config = live_config - if live_config_id is not None: - request.live_config_id = live_config_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_live_config] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - live_configs.LiveConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_live_configs(self, - request: Optional[Union[video_stitcher_service.ListLiveConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListLiveConfigsAsyncPager: - r"""Lists all live configs managed by the Video Stitcher - that belong to the specified project and region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_list_live_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest, dict]]): - The request object. Request message for - VideoStitcherService.listLiveConfig. - parent (:class:`str`): - Required. The project that contains the list of live - configs, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager: - Response message for - VideoStitcher.ListLiveConfig. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListLiveConfigsRequest): - request = video_stitcher_service.ListLiveConfigsRequest(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._client._transport._wrapped_methods[self._client._transport.list_live_configs] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListLiveConfigsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_live_config(self, - request: Optional[Union[video_stitcher_service.GetLiveConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> live_configs.LiveConfig: - r"""Returns the specified live config managed by the - Video Stitcher service. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_get_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_live_config(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetLiveConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.getLiveConfig. - name (:class:`str`): - Required. The name of the live config to be retrieved, - in the form of - ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveConfig: - Metadata for used to register live - configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetLiveConfigRequest): - request = video_stitcher_service.GetLiveConfigRequest(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._client._transport._wrapped_methods[self._client._transport.get_live_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_live_config(self, - request: Optional[Union[video_stitcher_service.DeleteLiveConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes the specified live config. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_delete_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteLiveConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_live_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.deleteLiveConfig. - name (:class:`str`): - Required. The name of the live config to be deleted, in - the form of - ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteLiveConfigRequest): - request = video_stitcher_service.DeleteLiveConfigRequest(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._client._transport._wrapped_methods[self._client._transport.delete_live_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_live_config(self, - request: Optional[Union[video_stitcher_service.UpdateLiveConfigRequest, dict]] = None, - *, - live_config: Optional[live_configs.LiveConfig] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the specified LiveConfig. Only update fields - specified in the call method body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_update_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.UpdateLiveConfigRequest( - live_config=live_config, - ) - - # Make the request - operation = client.update_live_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.updateLiveConfig. - live_config (:class:`google.cloud.video.stitcher_v1.types.LiveConfig`): - Required. The LiveConfig resource - which replaces the resource on the - server. - - This corresponds to the ``live_config`` 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 update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.LiveConfig` - Metadata for used to register live configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [live_config, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateLiveConfigRequest): - request = video_stitcher_service.UpdateLiveConfigRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if live_config is not None: - request.live_config = live_config - 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._client._transport._wrapped_methods[self._client._transport.update_live_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("live_config.name", request.live_config.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - live_configs.LiveConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def create_vod_config(self, - request: Optional[Union[video_stitcher_service.CreateVodConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - vod_config: Optional[vod_configs.VodConfig] = None, - vod_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Registers the VOD config with the provided unique ID - in the specified region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_create_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.CreateVodConfigRequest( - parent="parent_value", - vod_config_id="vod_config_id_value", - vod_config=vod_config, - ) - - # Make the request - operation = client.create_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.CreateVodConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.createVodConfig - parent (:class:`str`): - Required. The project in which the VOD config should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - vod_config (:class:`google.cloud.video.stitcher_v1.types.VodConfig`): - Required. The VOD config resource to - create. - - This corresponds to the ``vod_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - vod_config_id (:class:`str`): - Required. The unique identifier ID to - use for the VOD config. - - This corresponds to the ``vod_config_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.VodConfig` - Metadata used to register VOD configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, vod_config, vod_config_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateVodConfigRequest): - request = video_stitcher_service.CreateVodConfigRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if vod_config is not None: - request.vod_config = vod_config - if vod_config_id is not None: - request.vod_config_id = vod_config_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._client._transport._wrapped_methods[self._client._transport.create_vod_config] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - vod_configs.VodConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def list_vod_configs(self, - request: Optional[Union[video_stitcher_service.ListVodConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVodConfigsAsyncPager: - r"""Lists all VOD configs managed by the Video Stitcher - API that belong to the specified project and region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_list_vod_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.ListVodConfigsRequest, dict]]): - The request object. Request message for - VideoStitcherService.listVodConfig. - parent (:class:`str`): - Required. The project that contains the list of VOD - configs, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager: - Response message for - VideoStitcher.ListVodConfig. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListVodConfigsRequest): - request = video_stitcher_service.ListVodConfigsRequest(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._client._transport._wrapped_methods[self._client._transport.list_vod_configs] - - # 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), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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.ListVodConfigsAsyncPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_vod_config(self, - request: Optional[Union[video_stitcher_service.GetVodConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> vod_configs.VodConfig: - r"""Returns the specified VOD config managed by the Video - Stitcher API service. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_get_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_config(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.GetVodConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.getVodConfig. - name (:class:`str`): - Required. The name of the VOD config to be retrieved, in - the form of - ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodConfig: - Metadata used to register VOD - configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodConfigRequest): - request = video_stitcher_service.GetVodConfigRequest(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._client._transport._wrapped_methods[self._client._transport.get_vod_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_vod_config(self, - request: Optional[Union[video_stitcher_service.DeleteVodConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Deletes the specified VOD config. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_delete_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteVodConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.deleteVodConfig. - name (:class:`str`): - Required. The name of the VOD config to be deleted, in - the form of - ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteVodConfigRequest): - request = video_stitcher_service.DeleteVodConfigRequest(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._client._transport._wrapped_methods[self._client._transport.delete_vod_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - async def update_vod_config(self, - request: Optional[Union[video_stitcher_service.UpdateVodConfigRequest, dict]] = None, - *, - vod_config: Optional[vod_configs.VodConfig] = 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, Union[str, bytes]]] = (), - ) -> operation_async.AsyncOperation: - r"""Updates the specified VOD config. Only update fields - specified in the call method body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - async def sample_update_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.UpdateVodConfigRequest( - vod_config=vod_config, - ) - - # Make the request - operation = client.update_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest, dict]]): - The request object. Request message for - VideoStitcherService.updateVodConfig. - vod_config (:class:`google.cloud.video.stitcher_v1.types.VodConfig`): - Required. The VOD config resource - which replaces the resource on the - server. - - This corresponds to the ``vod_config`` 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 update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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_async.AsyncRetry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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.video.stitcher_v1.types.VodConfig` - Metadata used to register VOD configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [vod_config, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError("If the `request` argument is set, then none of " - "the individual field arguments should be set.") - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateVodConfigRequest): - request = video_stitcher_service.UpdateVodConfigRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if vod_config is not None: - request.vod_config = vod_config - 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._client._transport._wrapped_methods[self._client._transport.update_vod_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("vod_config.name", request.vod_config.name), - )), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, - vod_configs.VodConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # 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, Union[str, bytes]]] = (), - ) -> 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_async.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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 = self.transport._wrapped_methods[self._client._transport.list_operations] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # 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, Union[str, bytes]]] = (), - ) -> 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_async.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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 = self.transport._wrapped_methods[self._client._transport.get_operation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - response = await rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - async def delete_operation( - self, - request: Optional[operations_pb2.DeleteOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> None: - r"""Deletes a long-running operation. - - This method indicates that the client is no longer interested - in the operation result. It does not cancel the operation. - If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.DeleteOperationRequest`): - The request object. Request message for - `DeleteOperation` method. - retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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.DeleteOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self.transport._wrapped_methods[self._client._transport.delete_operation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - 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, Union[str, bytes]]] = (), - ) -> 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_async.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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 = self.transport._wrapped_methods[self._client._transport.cancel_operation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._client._validate_universe_domain() - - # Send the request. - await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - async def __aenter__(self) -> "VideoStitcherServiceAsyncClient": - 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__) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - - -__all__ = ( - "VideoStitcherServiceAsyncClient", -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py deleted file mode 100644 index 5410b0e72088..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py +++ /dev/null @@ -1,4651 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 http import HTTPStatus -import json -import logging as std_logging -import os -import re -from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast -import warnings - -from google.cloud.video.stitcher_v1 import gapic_version as package_version - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore -import google.protobuf - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - -from google.api_core import operation # type: ignore -from google.api_core import operation_async # type: ignore -from google.cloud.video.stitcher_v1.services.video_stitcher_service import pagers -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import fetch_options -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs -from google.longrunning import operations_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from .transports.base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import VideoStitcherServiceGrpcTransport -from .transports.grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport -from .transports.rest import VideoStitcherServiceRestTransport - - -class VideoStitcherServiceClientMeta(type): - """Metaclass for the VideoStitcherService 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[VideoStitcherServiceTransport]] - _transport_registry["grpc"] = VideoStitcherServiceGrpcTransport - _transport_registry["grpc_asyncio"] = VideoStitcherServiceGrpcAsyncIOTransport - _transport_registry["rest"] = VideoStitcherServiceRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[VideoStitcherServiceTransport]: - """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 VideoStitcherServiceClient(metaclass=VideoStitcherServiceClientMeta): - """Video-On-Demand content stitching API allows you to insert - ads into (VoD) video on demand files. You will be able to render - custom scrubber bars with highlighted ads, enforce ad policies, - allow seamless playback and tracking on native players and - monetize content with any standard VMAP compliant ad server. - """ - - @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") - - # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead. - DEFAULT_ENDPOINT = "videostitcher.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - _DEFAULT_ENDPOINT_TEMPLATE = "videostitcher.{UNIVERSE_DOMAIN}" - _DEFAULT_UNIVERSE = "googleapis.com" - - @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: - VideoStitcherServiceClient: 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: - VideoStitcherServiceClient: 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) -> VideoStitcherServiceTransport: - """Returns the transport used by the client instance. - - Returns: - VideoStitcherServiceTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def cdn_key_path(project: str,location: str,cdn_key: str,) -> str: - """Returns a fully-qualified cdn_key string.""" - return "projects/{project}/locations/{location}/cdnKeys/{cdn_key}".format(project=project, location=location, cdn_key=cdn_key, ) - - @staticmethod - def parse_cdn_key_path(path: str) -> Dict[str,str]: - """Parses a cdn_key path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/cdnKeys/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def live_ad_tag_detail_path(project: str,location: str,live_session: str,live_ad_tag_detail: str,) -> str: - """Returns a fully-qualified live_ad_tag_detail string.""" - return "projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}".format(project=project, location=location, live_session=live_session, live_ad_tag_detail=live_ad_tag_detail, ) - - @staticmethod - def parse_live_ad_tag_detail_path(path: str) -> Dict[str,str]: - """Parses a live_ad_tag_detail path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/liveSessions/(?P.+?)/liveAdTagDetails/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def live_config_path(project: str,location: str,live_config: str,) -> str: - """Returns a fully-qualified live_config string.""" - return "projects/{project}/locations/{location}/liveConfigs/{live_config}".format(project=project, location=location, live_config=live_config, ) - - @staticmethod - def parse_live_config_path(path: str) -> Dict[str,str]: - """Parses a live_config path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/liveConfigs/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def live_session_path(project: str,location: str,live_session: str,) -> str: - """Returns a fully-qualified live_session string.""" - return "projects/{project}/locations/{location}/liveSessions/{live_session}".format(project=project, location=location, live_session=live_session, ) - - @staticmethod - def parse_live_session_path(path: str) -> Dict[str,str]: - """Parses a live_session path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/liveSessions/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def slate_path(project: str,location: str,slate: str,) -> str: - """Returns a fully-qualified slate string.""" - return "projects/{project}/locations/{location}/slates/{slate}".format(project=project, location=location, slate=slate, ) - - @staticmethod - def parse_slate_path(path: str) -> Dict[str,str]: - """Parses a slate path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/slates/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def vod_ad_tag_detail_path(project: str,location: str,vod_session: str,vod_ad_tag_detail: str,) -> str: - """Returns a fully-qualified vod_ad_tag_detail string.""" - return "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodAdTagDetails/{vod_ad_tag_detail}".format(project=project, location=location, vod_session=vod_session, vod_ad_tag_detail=vod_ad_tag_detail, ) - - @staticmethod - def parse_vod_ad_tag_detail_path(path: str) -> Dict[str,str]: - """Parses a vod_ad_tag_detail path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodSessions/(?P.+?)/vodAdTagDetails/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def vod_config_path(project: str,location: str,vod_config: str,) -> str: - """Returns a fully-qualified vod_config string.""" - return "projects/{project}/locations/{location}/vodConfigs/{vod_config}".format(project=project, location=location, vod_config=vod_config, ) - - @staticmethod - def parse_vod_config_path(path: str) -> Dict[str,str]: - """Parses a vod_config path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodConfigs/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def vod_session_path(project: str,location: str,vod_session: str,) -> str: - """Returns a fully-qualified vod_session string.""" - return "projects/{project}/locations/{location}/vodSessions/{vod_session}".format(project=project, location=location, vod_session=vod_session, ) - - @staticmethod - def parse_vod_session_path(path: str) -> Dict[str,str]: - """Parses a vod_session path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodSessions/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def vod_stitch_detail_path(project: str,location: str,vod_session: str,vod_stitch_detail: str,) -> str: - """Returns a fully-qualified vod_stitch_detail string.""" - return "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodStitchDetails/{vod_stitch_detail}".format(project=project, location=location, vod_session=vod_session, vod_stitch_detail=vod_stitch_detail, ) - - @staticmethod - def parse_vod_stitch_detail_path(path: str) -> Dict[str,str]: - """Parses a vod_stitch_detail path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)/vodSessions/(?P.+?)/vodStitchDetails/(?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): - """Deprecated. 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. - """ - - warnings.warn("get_mtls_endpoint_and_cert_source is deprecated. Use the api_endpoint property instead.", - DeprecationWarning) - 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 - - @staticmethod - def _read_environment_variables(): - """Returns the environment variables used by the client. - - Returns: - Tuple[bool, str, str]: returns the GOOGLE_API_USE_CLIENT_CERTIFICATE, - GOOGLE_API_USE_MTLS_ENDPOINT, and GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variables. - - Raises: - ValueError: If GOOGLE_API_USE_CLIENT_CERTIFICATE is not - any of ["true", "false"]. - google.auth.exceptions.MutualTLSChannelError: If GOOGLE_API_USE_MTLS_ENDPOINT - is not any of ["auto", "never", "always"]. - """ - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false").lower() - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto").lower() - universe_domain_env = os.getenv("GOOGLE_CLOUD_UNIVERSE_DOMAIN") - 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`") - return use_client_cert == "true", use_mtls_endpoint, universe_domain_env - - @staticmethod - def _get_client_cert_source(provided_cert_source, use_cert_flag): - """Return the client cert source to be used by the client. - - Args: - provided_cert_source (bytes): The client certificate source provided. - use_cert_flag (bool): A flag indicating whether to use the client certificate. - - Returns: - bytes or None: The client cert source to be used by the client. - """ - client_cert_source = None - if use_cert_flag: - if provided_cert_source: - client_cert_source = provided_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - return client_cert_source - - @staticmethod - def _get_api_endpoint(api_override, client_cert_source, universe_domain, use_mtls_endpoint): - """Return the API endpoint used by the client. - - Args: - api_override (str): The API endpoint override. If specified, this is always - the return value of this function and the other arguments are not used. - client_cert_source (bytes): The client certificate source used by the client. - universe_domain (str): The universe domain used by the client. - use_mtls_endpoint (str): How to use the mTLS endpoint, which depends also on the other parameters. - Possible values are "always", "auto", or "never". - - Returns: - str: The API endpoint to be used by the client. - """ - if api_override is not None: - api_endpoint = api_override - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - _default_universe = VideoStitcherServiceClient._DEFAULT_UNIVERSE - if universe_domain != _default_universe: - raise MutualTLSChannelError(f"mTLS is not supported in any universe other than {_default_universe}.") - api_endpoint = VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=universe_domain) - return api_endpoint - - @staticmethod - def _get_universe_domain(client_universe_domain: Optional[str], universe_domain_env: Optional[str]) -> str: - """Return the universe domain used by the client. - - Args: - client_universe_domain (Optional[str]): The universe domain configured via the client options. - universe_domain_env (Optional[str]): The universe domain configured via the "GOOGLE_CLOUD_UNIVERSE_DOMAIN" environment variable. - - Returns: - str: The universe domain to be used by the client. - - Raises: - ValueError: If the universe domain is an empty string. - """ - universe_domain = VideoStitcherServiceClient._DEFAULT_UNIVERSE - if client_universe_domain is not None: - universe_domain = client_universe_domain - elif universe_domain_env is not None: - universe_domain = universe_domain_env - if len(universe_domain.strip()) == 0: - raise ValueError("Universe Domain cannot be an empty string.") - return universe_domain - - def _validate_universe_domain(self): - """Validates client's and credentials' universe domains are consistent. - - Returns: - bool: True iff the configured universe domain is valid. - - Raises: - ValueError: If the configured universe domain is not valid. - """ - - # NOTE (b/349488459): universe validation is disabled until further notice. - return True - - def _add_cred_info_for_auth_errors( - self, - error: core_exceptions.GoogleAPICallError - ) -> None: - """Adds credential info string to error details for 401/403/404 errors. - - Args: - error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info. - """ - if error.code not in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN, HTTPStatus.NOT_FOUND]: - return - - cred = self._transport._credentials - - # get_cred_info is only available in google-auth>=2.35.0 - if not hasattr(cred, "get_cred_info"): - return - - # ignore the type check since pypy test fails when get_cred_info - # is not available - cred_info = cred.get_cred_info() # type: ignore - if cred_info and hasattr(error._details, "append"): - error._details.append(json.dumps(cred_info)) - - @property - def api_endpoint(self): - """Return the API endpoint used by the client instance. - - Returns: - str: The API endpoint used by the client instance. - """ - return self._api_endpoint - - @property - def universe_domain(self) -> str: - """Return the universe domain used by the client instance. - - Returns: - str: The universe domain used by the client instance. - """ - return self._universe_domain - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, VideoStitcherServiceTransport, Callable[..., VideoStitcherServiceTransport]]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the video stitcher 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 (Optional[Union[str,VideoStitcherServiceTransport,Callable[..., VideoStitcherServiceTransport]]]): - The transport to use, or a Callable that constructs and returns a new transport. - If a Callable is given, it will be called with the same set of initialization - arguments as used in the VideoStitcherServiceTransport constructor. - 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. - - 1. The ``api_endpoint`` property can be used to override the - default endpoint provided by the client when ``transport`` is - not explicitly provided. Only if this property is not set and - ``transport`` was not explicitly provided, the endpoint is - determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment - variable, which have one of the following values: - "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). - - 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide a client certificate for mTLS 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. - - 3. The ``universe_domain`` property can be used to override the - default "googleapis.com" universe. Note that the ``api_endpoint`` - property still takes precedence; and ``universe_domain`` is - currently not supported for mTLS. - - 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. - """ - self._client_options = client_options - if isinstance(self._client_options, dict): - self._client_options = client_options_lib.from_dict(self._client_options) - if self._client_options is None: - self._client_options = client_options_lib.ClientOptions() - self._client_options = cast(client_options_lib.ClientOptions, self._client_options) - - universe_domain_opt = getattr(self._client_options, 'universe_domain', None) - - self._use_client_cert, self._use_mtls_endpoint, self._universe_domain_env = VideoStitcherServiceClient._read_environment_variables() - self._client_cert_source = VideoStitcherServiceClient._get_client_cert_source(self._client_options.client_cert_source, self._use_client_cert) - self._universe_domain = VideoStitcherServiceClient._get_universe_domain(universe_domain_opt, self._universe_domain_env) - self._api_endpoint = None # updated below, depending on `transport` - - # Initialize the universe domain validation. - self._is_universe_domain_valid = False - - if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER - # Setup logging. - client_logging.initialize_logging() - - api_key_value = getattr(self._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. - transport_provided = isinstance(transport, VideoStitcherServiceTransport) - if transport_provided: - # transport is a VideoStitcherServiceTransport instance. - if credentials or self._client_options.credentials_file or api_key_value: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if self._client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = cast(VideoStitcherServiceTransport, transport) - self._api_endpoint = self._transport.host - - self._api_endpoint = (self._api_endpoint or - VideoStitcherServiceClient._get_api_endpoint( - self._client_options.api_endpoint, - self._client_cert_source, - self._universe_domain, - self._use_mtls_endpoint)) - - if not transport_provided: - 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_init: Union[Type[VideoStitcherServiceTransport], Callable[..., VideoStitcherServiceTransport]] = ( - VideoStitcherServiceClient.get_transport_class(transport) - if isinstance(transport, str) or transport is None - else cast(Callable[..., VideoStitcherServiceTransport], transport) - ) - # initialize with the provided callable or the passed in class - self._transport = transport_init( - credentials=credentials, - credentials_file=self._client_options.credentials_file, - host=self._api_endpoint, - scopes=self._client_options.scopes, - client_cert_source_for_mtls=self._client_cert_source, - quota_project_id=self._client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - api_audience=self._client_options.api_audience, - ) - - if "async" not in str(self._transport): - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG): # pragma: NO COVER - _LOGGER.debug( - "Created client `google.cloud.video.stitcher_v1.VideoStitcherServiceClient`.", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "universeDomain": getattr(self._transport._credentials, "universe_domain", ""), - "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", - "credentialsInfo": getattr(self.transport._credentials, "get_cred_info", lambda: None)(), - } if hasattr(self._transport, "_credentials") else { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "credentialsType": None, - } - ) - - def create_cdn_key(self, - request: Optional[Union[video_stitcher_service.CreateCdnKeyRequest, dict]] = None, - *, - parent: Optional[str] = None, - cdn_key: Optional[cdn_keys.CdnKey] = None, - cdn_key_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates a new CDN key. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_create_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateCdnKeyRequest( - parent="parent_value", - cdn_key_id="cdn_key_id_value", - ) - - # Make the request - operation = client.create_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest, dict]): - The request object. Request message for - VideoStitcherService.createCdnKey. - parent (str): - Required. The project in which the CDN key should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): - Required. The CDN key resource to - create. - - This corresponds to the ``cdn_key`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - cdn_key_id (str): - Required. The ID to use for the CDN - key, which will become the final - component of the CDN key's resource - name. - - This value should conform to RFC-1034, - which restricts to lower-case letters, - numbers, and hyphen, with the first - character a letter, the last a letter or - a number, and a 63 character maximum. - - This corresponds to the ``cdn_key_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher - to sign URIs for fetching video manifests and signing - media segments for playback. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, cdn_key, cdn_key_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateCdnKeyRequest): - request = video_stitcher_service.CreateCdnKeyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if cdn_key is not None: - request.cdn_key = cdn_key - if cdn_key_id is not None: - request.cdn_key_id = cdn_key_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_cdn_key] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - cdn_keys.CdnKey, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_cdn_keys(self, - request: Optional[Union[video_stitcher_service.ListCdnKeysRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListCdnKeysPager: - r"""Lists all CDN keys in the specified project and - 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.video import stitcher_v1 - - def sample_list_cdn_keys(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListCdnKeysRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_cdn_keys(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.ListCdnKeysRequest, dict]): - The request object. Request message for - VideoStitcherService.listCdnKeys. - parent (str): - Required. The project that contains the list of CDN - keys, in the form of - ``projects/{project_number}/locations/{location}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager: - Response message for - VideoStitcher.ListCdnKeys. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListCdnKeysRequest): - request = video_stitcher_service.ListCdnKeysRequest(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_cdn_keys] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListCdnKeysPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_cdn_key(self, - request: Optional[Union[video_stitcher_service.GetCdnKeyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> cdn_keys.CdnKey: - r"""Returns the specified CDN key. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_get_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetCdnKeyRequest( - name="name_value", - ) - - # Make the request - response = client.get_cdn_key(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetCdnKeyRequest, dict]): - The request object. Request message for - VideoStitcherService.getCdnKey. - name (str): - Required. The name of the CDN key to be retrieved, in - the form of - ``projects/{project}/locations/{location}/cdnKeys/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.CdnKey: - Configuration for a CDN key. Used by - the Video Stitcher to sign URIs for - fetching video manifests and signing - media segments for playback. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetCdnKeyRequest): - request = video_stitcher_service.GetCdnKeyRequest(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_cdn_key] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_cdn_key(self, - request: Optional[Union[video_stitcher_service.DeleteCdnKeyRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes the specified CDN key. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_delete_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteCdnKeyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest, dict]): - The request object. Request message for - VideoStitcherService.deleteCdnKey. - name (str): - Required. The name of the CDN key to be deleted, in the - form of - ``projects/{project_number}/locations/{location}/cdnKeys/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteCdnKeyRequest): - request = video_stitcher_service.DeleteCdnKeyRequest(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_cdn_key] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_cdn_key(self, - request: Optional[Union[video_stitcher_service.UpdateCdnKeyRequest, dict]] = None, - *, - cdn_key: Optional[cdn_keys.CdnKey] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the specified CDN key. Only update fields - specified in the call method body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_update_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateCdnKeyRequest( - ) - - # Make the request - operation = client.update_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest, dict]): - The request object. Request message for - VideoStitcherService.updateCdnKey. - cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): - Required. The CDN key resource which - replaces the resource on the server. - - This corresponds to the ``cdn_key`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.video.stitcher_v1.types.CdnKey` Configuration for a CDN key. Used by the Video Stitcher - to sign URIs for fetching video manifests and signing - media segments for playback. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [cdn_key, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateCdnKeyRequest): - request = video_stitcher_service.UpdateCdnKeyRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if cdn_key is not None: - request.cdn_key = cdn_key - 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_cdn_key] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("cdn_key.name", request.cdn_key.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - cdn_keys.CdnKey, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_vod_session(self, - request: Optional[Union[video_stitcher_service.CreateVodSessionRequest, dict]] = None, - *, - parent: Optional[str] = None, - vod_session: Optional[sessions.VodSession] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.VodSession: - r"""Creates a client side playback VOD session and - returns the full tracking and playback metadata of the - 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.video import stitcher_v1 - - def sample_create_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - vod_session = stitcher_v1.VodSession() - vod_session.ad_tracking = "SERVER" - - request = stitcher_v1.CreateVodSessionRequest( - parent="parent_value", - vod_session=vod_session, - ) - - # Make the request - response = client.create_vod_session(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.CreateVodSessionRequest, dict]): - The request object. Request message for - VideoStitcherService.createVodSession - parent (str): - Required. The project and location in which the VOD - session should be created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - vod_session (google.cloud.video.stitcher_v1.types.VodSession): - Required. Parameters for creating a - session. - - This corresponds to the ``vod_session`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodSession: - Metadata for a VOD session. The - session expires 4 hours after its - creation. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, vod_session] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateVodSessionRequest): - request = video_stitcher_service.CreateVodSessionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if vod_session is not None: - request.vod_session = vod_session - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_vod_session] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_vod_session(self, - request: Optional[Union[video_stitcher_service.GetVodSessionRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.VodSession: - r"""Returns the full tracking, playback metadata, and - relevant ad-ops logs for the specified VOD 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.video import stitcher_v1 - - def sample_get_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodSessionRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_session(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetVodSessionRequest, dict]): - The request object. Request message for - VideoStitcherService.getVodSession - name (str): - Required. The name of the VOD session to be retrieved, - in the form of - ``projects/{project_number}/locations/{location}/vodSessions/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodSession: - Metadata for a VOD session. The - session expires 4 hours after its - creation. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodSessionRequest): - request = video_stitcher_service.GetVodSessionRequest(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_vod_session] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_vod_stitch_details(self, - request: Optional[Union[video_stitcher_service.ListVodStitchDetailsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVodStitchDetailsPager: - r"""Returns a list of detailed stitching information of - the specified VOD 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.video import stitcher_v1 - - def sample_list_vod_stitch_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodStitchDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_stitch_details(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest, dict]): - The request object. Request message for - VideoStitcherService.listVodStitchDetails. - parent (str): - Required. The VOD session where the stitch details - belong to, in the form of - ``projects/{project}/locations/{location}/vodSessions/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager: - Response message for - VideoStitcherService.listVodStitchDetails. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListVodStitchDetailsRequest): - request = video_stitcher_service.ListVodStitchDetailsRequest(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_vod_stitch_details] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListVodStitchDetailsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_vod_stitch_detail(self, - request: Optional[Union[video_stitcher_service.GetVodStitchDetailRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> stitch_details.VodStitchDetail: - r"""Returns the specified stitching information for the - specified VOD 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.video import stitcher_v1 - - def sample_get_vod_stitch_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodStitchDetailRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_stitch_detail(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest, dict]): - The request object. Request message for - VideoStitcherService.getVodStitchDetail. - name (str): - Required. The name of the stitch detail in the specified - VOD session, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodStitchDetail: - Information related to the - interstitial of a VOD session. This - resource is only available for VOD - sessions that do not implement Google Ad - Manager ad insertion. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodStitchDetailRequest): - request = video_stitcher_service.GetVodStitchDetailRequest(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_vod_stitch_detail] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_vod_ad_tag_details(self, - request: Optional[Union[video_stitcher_service.ListVodAdTagDetailsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVodAdTagDetailsPager: - r"""Return the list of ad tag details for the specified - VOD 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.video import stitcher_v1 - - def sample_list_vod_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_ad_tag_details(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest, dict]): - The request object. Request message for - VideoStitcherService.listVodAdTagDetails. - parent (str): - Required. The VOD session which the ad tag details - belong to, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager: - Response message for - VideoStitcherService.listVodAdTagDetails. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListVodAdTagDetailsRequest): - request = video_stitcher_service.ListVodAdTagDetailsRequest(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_vod_ad_tag_details] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListVodAdTagDetailsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_vod_ad_tag_detail(self, - request: Optional[Union[video_stitcher_service.GetVodAdTagDetailRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> ad_tag_details.VodAdTagDetail: - r"""Returns the specified ad tag detail for the specified - VOD 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.video import stitcher_v1 - - def sample_get_vod_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_ad_tag_detail(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest, dict]): - The request object. Request message for - VideoStitcherService.getVodAdTagDetail - name (str): - Required. The name of the ad tag detail for the - specified VOD session, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{vod_ad_tag_detail}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodAdTagDetail: - Information related to the details - for one ad tag. This resource is only - available for VOD sessions that do not - implement Google Ad Manager ad - insertion. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodAdTagDetailRequest): - request = video_stitcher_service.GetVodAdTagDetailRequest(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_vod_ad_tag_detail] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_live_ad_tag_details(self, - request: Optional[Union[video_stitcher_service.ListLiveAdTagDetailsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListLiveAdTagDetailsPager: - r"""Return the list of ad tag details for the specified - live 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.video import stitcher_v1 - - def sample_list_live_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_ad_tag_details(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest, dict]): - The request object. Request message for - VideoStitcherService.listLiveAdTagDetails. - parent (str): - Required. The resource parent in the form of - ``projects/{project}/locations/{location}/liveSessions/{live_session}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager: - Response message for - VideoStitcherService.listLiveAdTagDetails. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListLiveAdTagDetailsRequest): - request = video_stitcher_service.ListLiveAdTagDetailsRequest(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_live_ad_tag_details] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListLiveAdTagDetailsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_live_ad_tag_detail(self, - request: Optional[Union[video_stitcher_service.GetLiveAdTagDetailRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> ad_tag_details.LiveAdTagDetail: - r"""Returns the specified ad tag detail for the specified - live 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.video import stitcher_v1 - - def sample_get_live_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = client.get_live_ad_tag_detail(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest, dict]): - The request object. Request message for - VideoStitcherService.getLiveAdTagDetail - name (str): - Required. The resource name in the form of - ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveAdTagDetail: - Information related to the details - for one ad tag. This resource is only - available for live sessions that do not - implement Google Ad Manager ad - insertion. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetLiveAdTagDetailRequest): - request = video_stitcher_service.GetLiveAdTagDetailRequest(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_live_ad_tag_detail] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_slate(self, - request: Optional[Union[video_stitcher_service.CreateSlateRequest, dict]] = None, - *, - parent: Optional[str] = None, - slate: Optional[slates.Slate] = None, - slate_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Creates a slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_create_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateSlateRequest( - parent="parent_value", - slate_id="slate_id_value", - ) - - # Make the request - operation = client.create_slate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.CreateSlateRequest, dict]): - The request object. Request message for - VideoStitcherService.createSlate. - parent (str): - Required. The project in which the slate should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - slate (google.cloud.video.stitcher_v1.types.Slate): - Required. The slate to create. - This corresponds to the ``slate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - slate_id (str): - Required. The unique identifier for - the slate. This value should conform to - RFC-1034, which restricts to lower-case - letters, numbers, and hyphen, with the - first character a letter, the last a - letter or a number, and a 63 character - maximum. - - This corresponds to the ``slate_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.video.stitcher_v1.types.Slate` - Slate object - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, slate, slate_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateSlateRequest): - request = video_stitcher_service.CreateSlateRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if slate is not None: - request.slate = slate - if slate_id is not None: - request.slate_id = slate_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_slate] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - slates.Slate, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_slates(self, - request: Optional[Union[video_stitcher_service.ListSlatesRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListSlatesPager: - r"""Lists all slates in the specified project and - 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.video import stitcher_v1 - - def sample_list_slates(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListSlatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_slates(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.ListSlatesRequest, dict]): - The request object. Request message for - VideoStitcherService.listSlates. - parent (str): - Required. The project to list slates, in the form of - ``projects/{project_number}/locations/{location}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager: - Response message for - VideoStitcherService.listSlates. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListSlatesRequest): - request = video_stitcher_service.ListSlatesRequest(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_slates] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListSlatesPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_slate(self, - request: Optional[Union[video_stitcher_service.GetSlateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> slates.Slate: - r"""Returns the specified slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_get_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetSlateRequest( - name="name_value", - ) - - # Make the request - response = client.get_slate(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetSlateRequest, dict]): - The request object. Request message for - VideoStitcherService.getSlate. - name (str): - Required. The name of the slate to be retrieved, of the - slate, in the form of - ``projects/{project_number}/locations/{location}/slates/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.Slate: - Slate object - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetSlateRequest): - request = video_stitcher_service.GetSlateRequest(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_slate] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def update_slate(self, - request: Optional[Union[video_stitcher_service.UpdateSlateRequest, dict]] = None, - *, - slate: Optional[slates.Slate] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the specified slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_update_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateSlateRequest( - ) - - # Make the request - operation = client.update_slate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.UpdateSlateRequest, dict]): - The request object. Request message for - VideoStitcherService.updateSlate. - slate (google.cloud.video.stitcher_v1.types.Slate): - Required. The resource with updated - fields. - - This corresponds to the ``slate`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask which - specifies fields which should 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.video.stitcher_v1.types.Slate` - Slate object - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [slate, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateSlateRequest): - request = video_stitcher_service.UpdateSlateRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if slate is not None: - request.slate = slate - 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_slate] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("slate.name", request.slate.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - slates.Slate, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def delete_slate(self, - request: Optional[Union[video_stitcher_service.DeleteSlateRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes the specified slate. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_delete_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteSlateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_slate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.DeleteSlateRequest, dict]): - The request object. Request message for - VideoStitcherService.deleteSlate. - name (str): - Required. The name of the slate to be deleted, in the - form of - ``projects/{project_number}/locations/{location}/slates/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteSlateRequest): - request = video_stitcher_service.DeleteSlateRequest(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_slate] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_live_session(self, - request: Optional[Union[video_stitcher_service.CreateLiveSessionRequest, dict]] = None, - *, - parent: Optional[str] = None, - live_session: Optional[sessions.LiveSession] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.LiveSession: - r"""Creates a new live 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.video import stitcher_v1 - - def sample_create_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - live_session = stitcher_v1.LiveSession() - live_session.live_config = "live_config_value" - - request = stitcher_v1.CreateLiveSessionRequest( - parent="parent_value", - live_session=live_session, - ) - - # Make the request - response = client.create_live_session(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest, dict]): - The request object. Request message for - VideoStitcherService.createLiveSession. - parent (str): - Required. The project and location in which the live - session should be created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - live_session (google.cloud.video.stitcher_v1.types.LiveSession): - Required. Parameters for creating a - live session. - - This corresponds to the ``live_session`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveSession: - Metadata for a live session. The - session expires 5 minutes after the - client stops fetching the session's - playlists. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, live_session] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateLiveSessionRequest): - request = video_stitcher_service.CreateLiveSessionRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if live_session is not None: - request.live_session = live_session - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_live_session] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_live_session(self, - request: Optional[Union[video_stitcher_service.GetLiveSessionRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> sessions.LiveSession: - r"""Returns the details for the specified live 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.video import stitcher_v1 - - def sample_get_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveSessionRequest( - name="name_value", - ) - - # Make the request - response = client.get_live_session(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetLiveSessionRequest, dict]): - The request object. Request message for - VideoStitcherService.getSession. - name (str): - Required. The name of the live session, in the form of - ``projects/{project_number}/locations/{location}/liveSessions/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveSession: - Metadata for a live session. The - session expires 5 minutes after the - client stops fetching the session's - playlists. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetLiveSessionRequest): - request = video_stitcher_service.GetLiveSessionRequest(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_live_session] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def create_live_config(self, - request: Optional[Union[video_stitcher_service.CreateLiveConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - live_config: Optional[live_configs.LiveConfig] = None, - live_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Registers the live config with the provided unique ID - in the specified region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_create_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.CreateLiveConfigRequest( - parent="parent_value", - live_config_id="live_config_id_value", - live_config=live_config, - ) - - # Make the request - operation = client.create_live_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.createLiveConfig - parent (str): - Required. The project in which the live config should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - live_config (google.cloud.video.stitcher_v1.types.LiveConfig): - Required. The live config resource to - create. - - This corresponds to the ``live_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - live_config_id (str): - Required. The unique identifier ID to - use for the live config. - - This corresponds to the ``live_config_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.video.stitcher_v1.types.LiveConfig` - Metadata for used to register live configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, live_config, live_config_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateLiveConfigRequest): - request = video_stitcher_service.CreateLiveConfigRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if live_config is not None: - request.live_config = live_config - if live_config_id is not None: - request.live_config_id = live_config_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_live_config] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - live_configs.LiveConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_live_configs(self, - request: Optional[Union[video_stitcher_service.ListLiveConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListLiveConfigsPager: - r"""Lists all live configs managed by the Video Stitcher - that belong to the specified project and region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_list_live_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest, dict]): - The request object. Request message for - VideoStitcherService.listLiveConfig. - parent (str): - Required. The project that contains the list of live - configs, in the form of - ``projects/{project_number}/locations/{location}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager: - Response message for - VideoStitcher.ListLiveConfig. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListLiveConfigsRequest): - request = video_stitcher_service.ListLiveConfigsRequest(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_live_configs] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListLiveConfigsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_live_config(self, - request: Optional[Union[video_stitcher_service.GetLiveConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> live_configs.LiveConfig: - r"""Returns the specified live config managed by the - Video Stitcher service. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_get_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_live_config(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetLiveConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.getLiveConfig. - name (str): - Required. The name of the live config to be retrieved, - in the form of - ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.LiveConfig: - Metadata for used to register live - configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetLiveConfigRequest): - request = video_stitcher_service.GetLiveConfigRequest(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_live_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_live_config(self, - request: Optional[Union[video_stitcher_service.DeleteLiveConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes the specified live config. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_delete_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteLiveConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_live_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.deleteLiveConfig. - name (str): - Required. The name of the live config to be deleted, in - the form of - ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteLiveConfigRequest): - request = video_stitcher_service.DeleteLiveConfigRequest(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_live_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_live_config(self, - request: Optional[Union[video_stitcher_service.UpdateLiveConfigRequest, dict]] = None, - *, - live_config: Optional[live_configs.LiveConfig] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the specified LiveConfig. Only update fields - specified in the call method body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_update_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.UpdateLiveConfigRequest( - live_config=live_config, - ) - - # Make the request - operation = client.update_live_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.updateLiveConfig. - live_config (google.cloud.video.stitcher_v1.types.LiveConfig): - Required. The LiveConfig resource - which replaces the resource on the - server. - - This corresponds to the ``live_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.video.stitcher_v1.types.LiveConfig` - Metadata for used to register live configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [live_config, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateLiveConfigRequest): - request = video_stitcher_service.UpdateLiveConfigRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if live_config is not None: - request.live_config = live_config - 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_live_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("live_config.name", request.live_config.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - live_configs.LiveConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def create_vod_config(self, - request: Optional[Union[video_stitcher_service.CreateVodConfigRequest, dict]] = None, - *, - parent: Optional[str] = None, - vod_config: Optional[vod_configs.VodConfig] = None, - vod_config_id: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Registers the VOD config with the provided unique ID - in the specified region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_create_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.CreateVodConfigRequest( - parent="parent_value", - vod_config_id="vod_config_id_value", - vod_config=vod_config, - ) - - # Make the request - operation = client.create_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.CreateVodConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.createVodConfig - parent (str): - Required. The project in which the VOD config should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - vod_config (google.cloud.video.stitcher_v1.types.VodConfig): - Required. The VOD config resource to - create. - - This corresponds to the ``vod_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - vod_config_id (str): - Required. The unique identifier ID to - use for the VOD config. - - This corresponds to the ``vod_config_id`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.video.stitcher_v1.types.VodConfig` - Metadata used to register VOD configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [parent, vod_config, vod_config_id] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.CreateVodConfigRequest): - request = video_stitcher_service.CreateVodConfigRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if vod_config is not None: - request.vod_config = vod_config - if vod_config_id is not None: - request.vod_config_id = vod_config_id - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_vod_config] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - vod_configs.VodConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def list_vod_configs(self, - request: Optional[Union[video_stitcher_service.ListVodConfigsRequest, dict]] = None, - *, - parent: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> pagers.ListVodConfigsPager: - r"""Lists all VOD configs managed by the Video Stitcher - API that belong to the specified project and region. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_list_vod_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.ListVodConfigsRequest, dict]): - The request object. Request message for - VideoStitcherService.listVodConfig. - parent (str): - Required. The project that contains the list of VOD - configs, in the form of - ``projects/{project_number}/locations/{location}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager: - Response message for - VideoStitcher.ListVodConfig. - 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. - flattened_params = [parent] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.ListVodConfigsRequest): - request = video_stitcher_service.ListVodConfigsRequest(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_vod_configs] - - # 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), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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.ListVodConfigsPager( - method=rpc, - request=request, - response=response, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_vod_config(self, - request: Optional[Union[video_stitcher_service.GetVodConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> vod_configs.VodConfig: - r"""Returns the specified VOD config managed by the Video - Stitcher API service. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_get_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_config(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.GetVodConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.getVodConfig. - name (str): - Required. The name of the VOD config to be retrieved, in - the form of - ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.cloud.video.stitcher_v1.types.VodConfig: - Metadata used to register VOD - configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.GetVodConfigRequest): - request = video_stitcher_service.GetVodConfigRequest(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_vod_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_vod_config(self, - request: Optional[Union[video_stitcher_service.DeleteVodConfigRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Deletes the specified VOD config. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_delete_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteVodConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.deleteVodConfig. - name (str): - Required. The name of the VOD config to be deleted, in - the form of - ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - 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. - flattened_params = [name] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.DeleteVodConfigRequest): - request = video_stitcher_service.DeleteVodConfigRequest(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_vod_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("name", request.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def update_vod_config(self, - request: Optional[Union[video_stitcher_service.UpdateVodConfigRequest, dict]] = None, - *, - vod_config: Optional[vod_configs.VodConfig] = 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, Union[str, bytes]]] = (), - ) -> operation.Operation: - r"""Updates the specified VOD config. Only update fields - specified in the call method body. - - .. code-block:: python - - # This snippet has been automatically generated and should be regarded as a - # code template only. - # It will require modifications to work: - # - It may require correct/in-range values for request initialization. - # - It may require specifying regional endpoints when creating the service - # client as shown in: - # https://googleapis.dev/python/google-api-core/latest/client_options.html - from google.cloud.video import stitcher_v1 - - def sample_update_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.UpdateVodConfigRequest( - vod_config=vod_config, - ) - - # Make the request - operation = client.update_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest, dict]): - The request object. Request message for - VideoStitcherService.updateVodConfig. - vod_config (google.cloud.video.stitcher_v1.types.VodConfig): - Required. The VOD config resource - which replaces the resource on the - server. - - This corresponds to the ``vod_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For - the ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - - 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be - :class:`google.cloud.video.stitcher_v1.types.VodConfig` - Metadata used to register VOD configs. - - """ - # Create or coerce a protobuf request object. - # - Quick check: If we got a request object, we should *not* have - # gotten any keyword arguments that map to the request. - flattened_params = [vod_config, update_mask] - has_flattened_params = len([param for param in flattened_params if param is not None]) > 0 - if request is not None and has_flattened_params: - raise ValueError('If the `request` argument is set, then none of ' - 'the individual field arguments should be set.') - - # - Use the request object if provided (there's no risk of modifying the input as - # there are no flattened fields), or create one. - if not isinstance(request, video_stitcher_service.UpdateVodConfigRequest): - request = video_stitcher_service.UpdateVodConfigRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if vod_config is not None: - request.vod_config = vod_config - 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_vod_config] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("vod_config.name", request.vod_config.name), - )), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # 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, - vod_configs.VodConfig, - metadata_type=video_stitcher_service.OperationMetadata, - ) - - # Done; return the response. - return response - - def __enter__(self) -> "VideoStitcherServiceClient": - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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 = self._transport._wrapped_methods[self._transport.list_operations] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - try: - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - except core_exceptions.GoogleAPICallError as e: - self._add_cred_info_for_auth_errors(e) - raise e - - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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 = self._transport._wrapped_methods[self._transport.get_operation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - try: - # Send the request. - response = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - except core_exceptions.GoogleAPICallError as e: - self._add_cred_info_for_auth_errors(e) - raise e - - def delete_operation( - self, - request: Optional[operations_pb2.DeleteOperationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), - ) -> None: - r"""Deletes a long-running operation. - - This method indicates that the client is no longer interested - in the operation result. It does not cancel the operation. - If the server doesn't support this method, it returns - `google.rpc.Code.UNIMPLEMENTED`. - - Args: - request (:class:`~.operations_pb2.DeleteOperationRequest`): - The request object. Request message for - `DeleteOperation` method. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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.DeleteOperationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.delete_operation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - 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, Union[str, bytes]]] = (), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - 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 = self._transport._wrapped_methods[self._transport.cancel_operation] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata( - (("name", request.name),)), - ) - - # Validate the universe domain. - self._validate_universe_domain() - - # Send the request. - rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - - - - - - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - -__all__ = ( - "VideoStitcherServiceClient", -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py deleted file mode 100644 index ecdde06e2b11..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/pagers.py +++ /dev/null @@ -1,1006 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import retry_async as retries_async -from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator, Union -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] - OptionalAsyncRetry = Union[retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None] # type: ignore - -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs - - -class ListCdnKeysPager: - """A pager for iterating through ``list_cdn_keys`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` object, and - provides an ``__iter__`` method to iterate through its - ``cdn_keys`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListCdnKeys`` requests and continue to iterate - through the ``cdn_keys`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` - 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[..., video_stitcher_service.ListCdnKeysResponse], - request: video_stitcher_service.ListCdnKeysRequest, - response: video_stitcher_service.ListCdnKeysResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListCdnKeysRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListCdnKeysResponse): - The initial response object. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListCdnKeysRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[video_stitcher_service.ListCdnKeysResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[cdn_keys.CdnKey]: - for page in self.pages: - yield from page.cdn_keys - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListCdnKeysAsyncPager: - """A pager for iterating through ``list_cdn_keys`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``cdn_keys`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListCdnKeys`` requests and continue to iterate - through the ``cdn_keys`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListCdnKeysResponse` - 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[video_stitcher_service.ListCdnKeysResponse]], - request: video_stitcher_service.ListCdnKeysRequest, - response: video_stitcher_service.ListCdnKeysResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListCdnKeysRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListCdnKeysResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListCdnKeysRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[video_stitcher_service.ListCdnKeysResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[cdn_keys.CdnKey]: - async def async_generator(): - async for page in self.pages: - for response in page.cdn_keys: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVodStitchDetailsPager: - """A pager for iterating through ``list_vod_stitch_details`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``vod_stitch_details`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListVodStitchDetails`` requests and continue to iterate - through the ``vod_stitch_details`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` - 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[..., video_stitcher_service.ListVodStitchDetailsResponse], - request: video_stitcher_service.ListVodStitchDetailsRequest, - response: video_stitcher_service.ListVodStitchDetailsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse): - The initial response object. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListVodStitchDetailsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[video_stitcher_service.ListVodStitchDetailsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[stitch_details.VodStitchDetail]: - for page in self.pages: - yield from page.vod_stitch_details - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVodStitchDetailsAsyncPager: - """A pager for iterating through ``list_vod_stitch_details`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``vod_stitch_details`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListVodStitchDetails`` requests and continue to iterate - through the ``vod_stitch_details`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse` - 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[video_stitcher_service.ListVodStitchDetailsResponse]], - request: video_stitcher_service.ListVodStitchDetailsRequest, - response: video_stitcher_service.ListVodStitchDetailsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListVodStitchDetailsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListVodStitchDetailsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[video_stitcher_service.ListVodStitchDetailsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[stitch_details.VodStitchDetail]: - async def async_generator(): - async for page in self.pages: - for response in page.vod_stitch_details: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVodAdTagDetailsPager: - """A pager for iterating through ``list_vod_ad_tag_details`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``vod_ad_tag_details`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListVodAdTagDetails`` requests and continue to iterate - through the ``vod_ad_tag_details`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` - 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[..., video_stitcher_service.ListVodAdTagDetailsResponse], - request: video_stitcher_service.ListVodAdTagDetailsRequest, - response: video_stitcher_service.ListVodAdTagDetailsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse): - The initial response object. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListVodAdTagDetailsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[video_stitcher_service.ListVodAdTagDetailsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[ad_tag_details.VodAdTagDetail]: - for page in self.pages: - yield from page.vod_ad_tag_details - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVodAdTagDetailsAsyncPager: - """A pager for iterating through ``list_vod_ad_tag_details`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``vod_ad_tag_details`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListVodAdTagDetails`` requests and continue to iterate - through the ``vod_ad_tag_details`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse` - 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[video_stitcher_service.ListVodAdTagDetailsResponse]], - request: video_stitcher_service.ListVodAdTagDetailsRequest, - response: video_stitcher_service.ListVodAdTagDetailsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListVodAdTagDetailsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[video_stitcher_service.ListVodAdTagDetailsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[ad_tag_details.VodAdTagDetail]: - async def async_generator(): - async for page in self.pages: - for response in page.vod_ad_tag_details: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListLiveAdTagDetailsPager: - """A pager for iterating through ``list_live_ad_tag_details`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``live_ad_tag_details`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListLiveAdTagDetails`` requests and continue to iterate - through the ``live_ad_tag_details`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` - 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[..., video_stitcher_service.ListLiveAdTagDetailsResponse], - request: video_stitcher_service.ListLiveAdTagDetailsRequest, - response: video_stitcher_service.ListLiveAdTagDetailsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse): - The initial response object. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListLiveAdTagDetailsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[video_stitcher_service.ListLiveAdTagDetailsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[ad_tag_details.LiveAdTagDetail]: - for page in self.pages: - yield from page.live_ad_tag_details - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListLiveAdTagDetailsAsyncPager: - """A pager for iterating through ``list_live_ad_tag_details`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``live_ad_tag_details`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListLiveAdTagDetails`` requests and continue to iterate - through the ``live_ad_tag_details`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse` - 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[video_stitcher_service.ListLiveAdTagDetailsResponse]], - request: video_stitcher_service.ListLiveAdTagDetailsRequest, - response: video_stitcher_service.ListLiveAdTagDetailsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListLiveAdTagDetailsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[video_stitcher_service.ListLiveAdTagDetailsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[ad_tag_details.LiveAdTagDetail]: - async def async_generator(): - async for page in self.pages: - for response in page.live_ad_tag_details: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSlatesPager: - """A pager for iterating through ``list_slates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``slates`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListSlates`` requests and continue to iterate - through the ``slates`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` - 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[..., video_stitcher_service.ListSlatesResponse], - request: video_stitcher_service.ListSlatesRequest, - response: video_stitcher_service.ListSlatesResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListSlatesRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListSlatesResponse): - The initial response object. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListSlatesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[video_stitcher_service.ListSlatesResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[slates.Slate]: - for page in self.pages: - yield from page.slates - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSlatesAsyncPager: - """A pager for iterating through ``list_slates`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``slates`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListSlates`` requests and continue to iterate - through the ``slates`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListSlatesResponse` - 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[video_stitcher_service.ListSlatesResponse]], - request: video_stitcher_service.ListSlatesRequest, - response: video_stitcher_service.ListSlatesResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListSlatesRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListSlatesResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListSlatesRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[video_stitcher_service.ListSlatesResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[slates.Slate]: - async def async_generator(): - async for page in self.pages: - for response in page.slates: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListLiveConfigsPager: - """A pager for iterating through ``list_live_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``live_configs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListLiveConfigs`` requests and continue to iterate - through the ``live_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` - 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[..., video_stitcher_service.ListLiveConfigsResponse], - request: video_stitcher_service.ListLiveConfigsRequest, - response: video_stitcher_service.ListLiveConfigsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse): - The initial response object. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListLiveConfigsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[video_stitcher_service.ListLiveConfigsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[live_configs.LiveConfig]: - for page in self.pages: - yield from page.live_configs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListLiveConfigsAsyncPager: - """A pager for iterating through ``list_live_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``live_configs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListLiveConfigs`` requests and continue to iterate - through the ``live_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse` - 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[video_stitcher_service.ListLiveConfigsResponse]], - request: video_stitcher_service.ListLiveConfigsRequest, - response: video_stitcher_service.ListLiveConfigsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListLiveConfigsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListLiveConfigsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[video_stitcher_service.ListLiveConfigsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[live_configs.LiveConfig]: - async def async_generator(): - async for page in self.pages: - for response in page.live_configs: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVodConfigsPager: - """A pager for iterating through ``list_vod_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` object, and - provides an ``__iter__`` method to iterate through its - ``vod_configs`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListVodConfigs`` requests and continue to iterate - through the ``vod_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` - 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[..., video_stitcher_service.ListVodConfigsResponse], - request: video_stitcher_service.ListVodConfigsRequest, - response: video_stitcher_service.ListVodConfigsResponse, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListVodConfigsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListVodConfigsResponse): - The initial response object. - retry (google.api_core.retry.Retry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListVodConfigsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[video_stitcher_service.ListVodConfigsResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterator[vod_configs.VodConfig]: - for page in self.pages: - yield from page.vod_configs - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListVodConfigsAsyncPager: - """A pager for iterating through ``list_vod_configs`` requests. - - This class thinly wraps an initial - :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``vod_configs`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListVodConfigs`` requests and continue to iterate - through the ``vod_configs`` field on the - corresponding responses. - - All the usual :class:`google.cloud.video.stitcher_v1.types.ListVodConfigsResponse` - 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[video_stitcher_service.ListVodConfigsResponse]], - request: video_stitcher_service.ListVodConfigsRequest, - response: video_stitcher_service.ListVodConfigsResponse, - *, - retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()): - """Instantiates the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.cloud.video.stitcher_v1.types.ListVodConfigsRequest): - The initial request object. - response (google.cloud.video.stitcher_v1.types.ListVodConfigsResponse): - The initial response object. - retry (google.api_core.retry.AsyncRetry): Designation of what errors, - if any, should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - self._method = method - self._request = video_stitcher_service.ListVodConfigsRequest(request) - self._response = response - self._retry = retry - self._timeout = timeout - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[video_stitcher_service.ListVodConfigsResponse]: - 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, retry=self._retry, timeout=self._timeout, metadata=self._metadata) - yield self._response - def __aiter__(self) -> AsyncIterator[vod_configs.VodConfig]: - async def async_generator(): - async for page in self.pages: - for response in page.vod_configs: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst deleted file mode 100644 index b28f3c61e27f..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/README.rst +++ /dev/null @@ -1,9 +0,0 @@ - -transport inheritance structure -_______________________________ - -`VideoStitcherServiceTransport` is the ABC for all transports. -- public child `VideoStitcherServiceGrpcTransport` for sync gRPC transport (defined in `grpc.py`). -- public child `VideoStitcherServiceGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`). -- private child `_BaseVideoStitcherServiceRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`). -- public child `VideoStitcherServiceRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`). diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py deleted file mode 100644 index 0498bf5348c2..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 VideoStitcherServiceTransport -from .grpc import VideoStitcherServiceGrpcTransport -from .grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport -from .rest import VideoStitcherServiceRestTransport -from .rest import VideoStitcherServiceRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[VideoStitcherServiceTransport]] -_transport_registry['grpc'] = VideoStitcherServiceGrpcTransport -_transport_registry['grpc_asyncio'] = VideoStitcherServiceGrpcAsyncIOTransport -_transport_registry['rest'] = VideoStitcherServiceRestTransport - -__all__ = ( - 'VideoStitcherServiceTransport', - 'VideoStitcherServiceGrpcTransport', - 'VideoStitcherServiceGrpcAsyncIOTransport', - 'VideoStitcherServiceRestTransport', - 'VideoStitcherServiceRestInterceptor', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py deleted file mode 100644 index 5d82d004a057..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/base.py +++ /dev/null @@ -1,635 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher_v1 import gapic_version as package_version - -import google.auth # type: ignore -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.api_core import operations_v1 -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore -import google.protobuf - -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs -from google.longrunning import operations_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - - -class VideoStitcherServiceTransport(abc.ABC): - """Abstract transport class for VideoStitcherService.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'videostitcher.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 (default: 'videostitcher.googleapis.com'). - 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 not hasattr(self, "_ignore_credentials"): - self._ignore_credentials: bool = False - - # 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 and not self._ignore_credentials: - 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 - - @property - def host(self): - return self._host - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.create_cdn_key: gapic_v1.method.wrap_method( - self.create_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.list_cdn_keys: gapic_v1.method.wrap_method( - self.list_cdn_keys, - default_timeout=60.0, - client_info=client_info, - ), - self.get_cdn_key: gapic_v1.method.wrap_method( - self.get_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_cdn_key: gapic_v1.method.wrap_method( - self.delete_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.update_cdn_key: gapic_v1.method.wrap_method( - self.update_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.create_vod_session: gapic_v1.method.wrap_method( - self.create_vod_session, - default_timeout=60.0, - client_info=client_info, - ), - self.get_vod_session: gapic_v1.method.wrap_method( - self.get_vod_session, - default_timeout=60.0, - client_info=client_info, - ), - self.list_vod_stitch_details: gapic_v1.method.wrap_method( - self.list_vod_stitch_details, - default_timeout=60.0, - client_info=client_info, - ), - self.get_vod_stitch_detail: gapic_v1.method.wrap_method( - self.get_vod_stitch_detail, - default_timeout=60.0, - client_info=client_info, - ), - self.list_vod_ad_tag_details: gapic_v1.method.wrap_method( - self.list_vod_ad_tag_details, - default_timeout=60.0, - client_info=client_info, - ), - self.get_vod_ad_tag_detail: gapic_v1.method.wrap_method( - self.get_vod_ad_tag_detail, - default_timeout=60.0, - client_info=client_info, - ), - self.list_live_ad_tag_details: gapic_v1.method.wrap_method( - self.list_live_ad_tag_details, - default_timeout=60.0, - client_info=client_info, - ), - self.get_live_ad_tag_detail: gapic_v1.method.wrap_method( - self.get_live_ad_tag_detail, - default_timeout=60.0, - client_info=client_info, - ), - self.create_slate: gapic_v1.method.wrap_method( - self.create_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.list_slates: gapic_v1.method.wrap_method( - self.list_slates, - default_timeout=60.0, - client_info=client_info, - ), - self.get_slate: gapic_v1.method.wrap_method( - self.get_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.update_slate: gapic_v1.method.wrap_method( - self.update_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_slate: gapic_v1.method.wrap_method( - self.delete_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.create_live_session: gapic_v1.method.wrap_method( - self.create_live_session, - default_timeout=60.0, - client_info=client_info, - ), - self.get_live_session: gapic_v1.method.wrap_method( - self.get_live_session, - default_timeout=60.0, - client_info=client_info, - ), - self.create_live_config: gapic_v1.method.wrap_method( - self.create_live_config, - default_timeout=60.0, - client_info=client_info, - ), - self.list_live_configs: gapic_v1.method.wrap_method( - self.list_live_configs, - default_timeout=60.0, - client_info=client_info, - ), - self.get_live_config: gapic_v1.method.wrap_method( - self.get_live_config, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_live_config: gapic_v1.method.wrap_method( - self.delete_live_config, - default_timeout=60.0, - client_info=client_info, - ), - self.update_live_config: gapic_v1.method.wrap_method( - self.update_live_config, - default_timeout=None, - client_info=client_info, - ), - self.create_vod_config: gapic_v1.method.wrap_method( - self.create_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.list_vod_configs: gapic_v1.method.wrap_method( - self.list_vod_configs, - default_timeout=None, - client_info=client_info, - ), - self.get_vod_config: gapic_v1.method.wrap_method( - self.get_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.delete_vod_config: gapic_v1.method.wrap_method( - self.delete_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.update_vod_config: gapic_v1.method.wrap_method( - self.update_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.cancel_operation: gapic_v1.method.wrap_method( - self.cancel_operation, - default_timeout=None, - client_info=client_info, - ), - self.delete_operation: gapic_v1.method.wrap_method( - self.delete_operation, - default_timeout=None, - client_info=client_info, - ), - self.get_operation: gapic_v1.method.wrap_method( - self.get_operation, - default_timeout=None, - client_info=client_info, - ), - self.list_operations: gapic_v1.method.wrap_method( - self.list_operations, - 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_cdn_key(self) -> Callable[ - [video_stitcher_service.CreateCdnKeyRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_cdn_keys(self) -> Callable[ - [video_stitcher_service.ListCdnKeysRequest], - Union[ - video_stitcher_service.ListCdnKeysResponse, - Awaitable[video_stitcher_service.ListCdnKeysResponse] - ]]: - raise NotImplementedError() - - @property - def get_cdn_key(self) -> Callable[ - [video_stitcher_service.GetCdnKeyRequest], - Union[ - cdn_keys.CdnKey, - Awaitable[cdn_keys.CdnKey] - ]]: - raise NotImplementedError() - - @property - def delete_cdn_key(self) -> Callable[ - [video_stitcher_service.DeleteCdnKeyRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_cdn_key(self) -> Callable[ - [video_stitcher_service.UpdateCdnKeyRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_vod_session(self) -> Callable[ - [video_stitcher_service.CreateVodSessionRequest], - Union[ - sessions.VodSession, - Awaitable[sessions.VodSession] - ]]: - raise NotImplementedError() - - @property - def get_vod_session(self) -> Callable[ - [video_stitcher_service.GetVodSessionRequest], - Union[ - sessions.VodSession, - Awaitable[sessions.VodSession] - ]]: - raise NotImplementedError() - - @property - def list_vod_stitch_details(self) -> Callable[ - [video_stitcher_service.ListVodStitchDetailsRequest], - Union[ - video_stitcher_service.ListVodStitchDetailsResponse, - Awaitable[video_stitcher_service.ListVodStitchDetailsResponse] - ]]: - raise NotImplementedError() - - @property - def get_vod_stitch_detail(self) -> Callable[ - [video_stitcher_service.GetVodStitchDetailRequest], - Union[ - stitch_details.VodStitchDetail, - Awaitable[stitch_details.VodStitchDetail] - ]]: - raise NotImplementedError() - - @property - def list_vod_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListVodAdTagDetailsRequest], - Union[ - video_stitcher_service.ListVodAdTagDetailsResponse, - Awaitable[video_stitcher_service.ListVodAdTagDetailsResponse] - ]]: - raise NotImplementedError() - - @property - def get_vod_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetVodAdTagDetailRequest], - Union[ - ad_tag_details.VodAdTagDetail, - Awaitable[ad_tag_details.VodAdTagDetail] - ]]: - raise NotImplementedError() - - @property - def list_live_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListLiveAdTagDetailsRequest], - Union[ - video_stitcher_service.ListLiveAdTagDetailsResponse, - Awaitable[video_stitcher_service.ListLiveAdTagDetailsResponse] - ]]: - raise NotImplementedError() - - @property - def get_live_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetLiveAdTagDetailRequest], - Union[ - ad_tag_details.LiveAdTagDetail, - Awaitable[ad_tag_details.LiveAdTagDetail] - ]]: - raise NotImplementedError() - - @property - def create_slate(self) -> Callable[ - [video_stitcher_service.CreateSlateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_slates(self) -> Callable[ - [video_stitcher_service.ListSlatesRequest], - Union[ - video_stitcher_service.ListSlatesResponse, - Awaitable[video_stitcher_service.ListSlatesResponse] - ]]: - raise NotImplementedError() - - @property - def get_slate(self) -> Callable[ - [video_stitcher_service.GetSlateRequest], - Union[ - slates.Slate, - Awaitable[slates.Slate] - ]]: - raise NotImplementedError() - - @property - def update_slate(self) -> Callable[ - [video_stitcher_service.UpdateSlateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def delete_slate(self) -> Callable[ - [video_stitcher_service.DeleteSlateRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_live_session(self) -> Callable[ - [video_stitcher_service.CreateLiveSessionRequest], - Union[ - sessions.LiveSession, - Awaitable[sessions.LiveSession] - ]]: - raise NotImplementedError() - - @property - def get_live_session(self) -> Callable[ - [video_stitcher_service.GetLiveSessionRequest], - Union[ - sessions.LiveSession, - Awaitable[sessions.LiveSession] - ]]: - raise NotImplementedError() - - @property - def create_live_config(self) -> Callable[ - [video_stitcher_service.CreateLiveConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_live_configs(self) -> Callable[ - [video_stitcher_service.ListLiveConfigsRequest], - Union[ - video_stitcher_service.ListLiveConfigsResponse, - Awaitable[video_stitcher_service.ListLiveConfigsResponse] - ]]: - raise NotImplementedError() - - @property - def get_live_config(self) -> Callable[ - [video_stitcher_service.GetLiveConfigRequest], - Union[ - live_configs.LiveConfig, - Awaitable[live_configs.LiveConfig] - ]]: - raise NotImplementedError() - - @property - def delete_live_config(self) -> Callable[ - [video_stitcher_service.DeleteLiveConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_live_config(self) -> Callable[ - [video_stitcher_service.UpdateLiveConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def create_vod_config(self) -> Callable[ - [video_stitcher_service.CreateVodConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def list_vod_configs(self) -> Callable[ - [video_stitcher_service.ListVodConfigsRequest], - Union[ - video_stitcher_service.ListVodConfigsResponse, - Awaitable[video_stitcher_service.ListVodConfigsResponse] - ]]: - raise NotImplementedError() - - @property - def get_vod_config(self) -> Callable[ - [video_stitcher_service.GetVodConfigRequest], - Union[ - vod_configs.VodConfig, - Awaitable[vod_configs.VodConfig] - ]]: - raise NotImplementedError() - - @property - def delete_vod_config(self) -> Callable[ - [video_stitcher_service.DeleteVodConfigRequest], - Union[ - operations_pb2.Operation, - Awaitable[operations_pb2.Operation] - ]]: - raise NotImplementedError() - - @property - def update_vod_config(self) -> Callable[ - [video_stitcher_service.UpdateVodConfigRequest], - 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 delete_operation( - self, - ) -> Callable[ - [operations_pb2.DeleteOperationRequest], - None, - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'VideoStitcherServiceTransport', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py deleted file mode 100644 index 44e6aa81768a..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc.py +++ /dev/null @@ -1,1222 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 json -import logging as std_logging -import pickle -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 -from google.protobuf.json_format import MessageToJson -import google.protobuf.message - -import grpc # type: ignore -import proto # type: ignore - -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs -from google.longrunning import operations_pb2 # type: ignore -from .base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - - -class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER - def intercept_unary_unary(self, continuation, client_call_details, request): - logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) - if logging_enabled: # pragma: NO COVER - request_metadata = client_call_details.metadata - if isinstance(request, proto.Message): - request_payload = type(request).to_json(request) - elif isinstance(request, google.protobuf.message.Message): - request_payload = MessageToJson(request) - else: - request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" - - request_metadata = { - key: value.decode("utf-8") if isinstance(value, bytes) else value - for key, value in request_metadata - } - grpc_request = { - "payload": request_payload, - "requestMethod": "grpc", - "metadata": dict(request_metadata), - } - _LOGGER.debug( - f"Sending request for {client_call_details.method}", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": str(client_call_details.method), - "request": grpc_request, - "metadata": grpc_request["metadata"], - }, - ) - response = continuation(client_call_details, request) - if logging_enabled: # pragma: NO COVER - response_metadata = response.trailing_metadata() - # Convert gRPC metadata `` to list of tuples - metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None - result = response.result() - if isinstance(result, proto.Message): - response_payload = type(result).to_json(result) - elif isinstance(result, google.protobuf.message.Message): - response_payload = MessageToJson(result) - else: - response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" - grpc_response = { - "payload": response_payload, - "metadata": metadata, - "status": "OK", - } - _LOGGER.debug( - f"Received response for {client_call_details.method}.", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": client_call_details.method, - "response": grpc_response, - "metadata": grpc_response["metadata"], - }, - ) - return response - - -class VideoStitcherServiceGrpcTransport(VideoStitcherServiceTransport): - """gRPC backend transport for VideoStitcherService. - - Video-On-Demand content stitching API allows you to insert - ads into (VoD) video on demand files. You will be able to render - custom scrubber bars with highlighted ads, enforce ad policies, - allow seamless playback and tracking on native players and - monetize content with any standard VMAP compliant ad server. - - 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 = 'videostitcher.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[grpc.Channel, Callable[..., 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 (default: 'videostitcher.googleapis.com'). - 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 a ``channel`` instance 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 a ``channel`` instance is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if a ``channel`` instance is provided. - channel (Optional[Union[grpc.Channel, Callable[..., grpc.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - 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 a ``channel`` instance 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 a ``channel`` instance 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 isinstance(channel, grpc.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # 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: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - 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), - ], - ) - - self._interceptor = _LoggingClientInterceptor() - self._logged_channel = grpc.intercept_channel(self._grpc_channel, self._interceptor) - - # Wrap messages. This must be done after self._logged_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'videostitcher.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._logged_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_cdn_key(self) -> Callable[ - [video_stitcher_service.CreateCdnKeyRequest], - operations_pb2.Operation]: - r"""Return a callable for the create cdn key method over gRPC. - - Creates a new CDN key. - - Returns: - Callable[[~.CreateCdnKeyRequest], - ~.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_cdn_key' not in self._stubs: - self._stubs['create_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateCdnKey', - request_serializer=video_stitcher_service.CreateCdnKeyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_cdn_key'] - - @property - def list_cdn_keys(self) -> Callable[ - [video_stitcher_service.ListCdnKeysRequest], - video_stitcher_service.ListCdnKeysResponse]: - r"""Return a callable for the list cdn keys method over gRPC. - - Lists all CDN keys in the specified project and - location. - - Returns: - Callable[[~.ListCdnKeysRequest], - ~.ListCdnKeysResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_cdn_keys' not in self._stubs: - self._stubs['list_cdn_keys'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListCdnKeys', - request_serializer=video_stitcher_service.ListCdnKeysRequest.serialize, - response_deserializer=video_stitcher_service.ListCdnKeysResponse.deserialize, - ) - return self._stubs['list_cdn_keys'] - - @property - def get_cdn_key(self) -> Callable[ - [video_stitcher_service.GetCdnKeyRequest], - cdn_keys.CdnKey]: - r"""Return a callable for the get cdn key method over gRPC. - - Returns the specified CDN key. - - Returns: - Callable[[~.GetCdnKeyRequest], - ~.CdnKey]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_cdn_key' not in self._stubs: - self._stubs['get_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetCdnKey', - request_serializer=video_stitcher_service.GetCdnKeyRequest.serialize, - response_deserializer=cdn_keys.CdnKey.deserialize, - ) - return self._stubs['get_cdn_key'] - - @property - def delete_cdn_key(self) -> Callable[ - [video_stitcher_service.DeleteCdnKeyRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete cdn key method over gRPC. - - Deletes the specified CDN key. - - Returns: - Callable[[~.DeleteCdnKeyRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_cdn_key' not in self._stubs: - self._stubs['delete_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteCdnKey', - request_serializer=video_stitcher_service.DeleteCdnKeyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_cdn_key'] - - @property - def update_cdn_key(self) -> Callable[ - [video_stitcher_service.UpdateCdnKeyRequest], - operations_pb2.Operation]: - r"""Return a callable for the update cdn key method over gRPC. - - Updates the specified CDN key. Only update fields - specified in the call method body. - - Returns: - Callable[[~.UpdateCdnKeyRequest], - ~.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_cdn_key' not in self._stubs: - self._stubs['update_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateCdnKey', - request_serializer=video_stitcher_service.UpdateCdnKeyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_cdn_key'] - - @property - def create_vod_session(self) -> Callable[ - [video_stitcher_service.CreateVodSessionRequest], - sessions.VodSession]: - r"""Return a callable for the create vod session method over gRPC. - - Creates a client side playback VOD session and - returns the full tracking and playback metadata of the - session. - - Returns: - Callable[[~.CreateVodSessionRequest], - ~.VodSession]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_session' not in self._stubs: - self._stubs['create_vod_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodSession', - request_serializer=video_stitcher_service.CreateVodSessionRequest.serialize, - response_deserializer=sessions.VodSession.deserialize, - ) - return self._stubs['create_vod_session'] - - @property - def get_vod_session(self) -> Callable[ - [video_stitcher_service.GetVodSessionRequest], - sessions.VodSession]: - r"""Return a callable for the get vod session method over gRPC. - - Returns the full tracking, playback metadata, and - relevant ad-ops logs for the specified VOD session. - - Returns: - Callable[[~.GetVodSessionRequest], - ~.VodSession]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_session' not in self._stubs: - self._stubs['get_vod_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodSession', - request_serializer=video_stitcher_service.GetVodSessionRequest.serialize, - response_deserializer=sessions.VodSession.deserialize, - ) - return self._stubs['get_vod_session'] - - @property - def list_vod_stitch_details(self) -> Callable[ - [video_stitcher_service.ListVodStitchDetailsRequest], - video_stitcher_service.ListVodStitchDetailsResponse]: - r"""Return a callable for the list vod stitch details method over gRPC. - - Returns a list of detailed stitching information of - the specified VOD session. - - Returns: - Callable[[~.ListVodStitchDetailsRequest], - ~.ListVodStitchDetailsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_stitch_details' not in self._stubs: - self._stubs['list_vod_stitch_details'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodStitchDetails', - request_serializer=video_stitcher_service.ListVodStitchDetailsRequest.serialize, - response_deserializer=video_stitcher_service.ListVodStitchDetailsResponse.deserialize, - ) - return self._stubs['list_vod_stitch_details'] - - @property - def get_vod_stitch_detail(self) -> Callable[ - [video_stitcher_service.GetVodStitchDetailRequest], - stitch_details.VodStitchDetail]: - r"""Return a callable for the get vod stitch detail method over gRPC. - - Returns the specified stitching information for the - specified VOD session. - - Returns: - Callable[[~.GetVodStitchDetailRequest], - ~.VodStitchDetail]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_stitch_detail' not in self._stubs: - self._stubs['get_vod_stitch_detail'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodStitchDetail', - request_serializer=video_stitcher_service.GetVodStitchDetailRequest.serialize, - response_deserializer=stitch_details.VodStitchDetail.deserialize, - ) - return self._stubs['get_vod_stitch_detail'] - - @property - def list_vod_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListVodAdTagDetailsRequest], - video_stitcher_service.ListVodAdTagDetailsResponse]: - r"""Return a callable for the list vod ad tag details method over gRPC. - - Return the list of ad tag details for the specified - VOD session. - - Returns: - Callable[[~.ListVodAdTagDetailsRequest], - ~.ListVodAdTagDetailsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_ad_tag_details' not in self._stubs: - self._stubs['list_vod_ad_tag_details'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodAdTagDetails', - request_serializer=video_stitcher_service.ListVodAdTagDetailsRequest.serialize, - response_deserializer=video_stitcher_service.ListVodAdTagDetailsResponse.deserialize, - ) - return self._stubs['list_vod_ad_tag_details'] - - @property - def get_vod_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetVodAdTagDetailRequest], - ad_tag_details.VodAdTagDetail]: - r"""Return a callable for the get vod ad tag detail method over gRPC. - - Returns the specified ad tag detail for the specified - VOD session. - - Returns: - Callable[[~.GetVodAdTagDetailRequest], - ~.VodAdTagDetail]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_ad_tag_detail' not in self._stubs: - self._stubs['get_vod_ad_tag_detail'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodAdTagDetail', - request_serializer=video_stitcher_service.GetVodAdTagDetailRequest.serialize, - response_deserializer=ad_tag_details.VodAdTagDetail.deserialize, - ) - return self._stubs['get_vod_ad_tag_detail'] - - @property - def list_live_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListLiveAdTagDetailsRequest], - video_stitcher_service.ListLiveAdTagDetailsResponse]: - r"""Return a callable for the list live ad tag details method over gRPC. - - Return the list of ad tag details for the specified - live session. - - Returns: - Callable[[~.ListLiveAdTagDetailsRequest], - ~.ListLiveAdTagDetailsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_ad_tag_details' not in self._stubs: - self._stubs['list_live_ad_tag_details'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveAdTagDetails', - request_serializer=video_stitcher_service.ListLiveAdTagDetailsRequest.serialize, - response_deserializer=video_stitcher_service.ListLiveAdTagDetailsResponse.deserialize, - ) - return self._stubs['list_live_ad_tag_details'] - - @property - def get_live_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetLiveAdTagDetailRequest], - ad_tag_details.LiveAdTagDetail]: - r"""Return a callable for the get live ad tag detail method over gRPC. - - Returns the specified ad tag detail for the specified - live session. - - Returns: - Callable[[~.GetLiveAdTagDetailRequest], - ~.LiveAdTagDetail]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_ad_tag_detail' not in self._stubs: - self._stubs['get_live_ad_tag_detail'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveAdTagDetail', - request_serializer=video_stitcher_service.GetLiveAdTagDetailRequest.serialize, - response_deserializer=ad_tag_details.LiveAdTagDetail.deserialize, - ) - return self._stubs['get_live_ad_tag_detail'] - - @property - def create_slate(self) -> Callable[ - [video_stitcher_service.CreateSlateRequest], - operations_pb2.Operation]: - r"""Return a callable for the create slate method over gRPC. - - Creates a slate. - - Returns: - Callable[[~.CreateSlateRequest], - ~.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_slate' not in self._stubs: - self._stubs['create_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateSlate', - request_serializer=video_stitcher_service.CreateSlateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_slate'] - - @property - def list_slates(self) -> Callable[ - [video_stitcher_service.ListSlatesRequest], - video_stitcher_service.ListSlatesResponse]: - r"""Return a callable for the list slates method over gRPC. - - Lists all slates in the specified project and - location. - - Returns: - Callable[[~.ListSlatesRequest], - ~.ListSlatesResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_slates' not in self._stubs: - self._stubs['list_slates'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListSlates', - request_serializer=video_stitcher_service.ListSlatesRequest.serialize, - response_deserializer=video_stitcher_service.ListSlatesResponse.deserialize, - ) - return self._stubs['list_slates'] - - @property - def get_slate(self) -> Callable[ - [video_stitcher_service.GetSlateRequest], - slates.Slate]: - r"""Return a callable for the get slate method over gRPC. - - Returns the specified slate. - - Returns: - Callable[[~.GetSlateRequest], - ~.Slate]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_slate' not in self._stubs: - self._stubs['get_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetSlate', - request_serializer=video_stitcher_service.GetSlateRequest.serialize, - response_deserializer=slates.Slate.deserialize, - ) - return self._stubs['get_slate'] - - @property - def update_slate(self) -> Callable[ - [video_stitcher_service.UpdateSlateRequest], - operations_pb2.Operation]: - r"""Return a callable for the update slate method over gRPC. - - Updates the specified slate. - - Returns: - Callable[[~.UpdateSlateRequest], - ~.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_slate' not in self._stubs: - self._stubs['update_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateSlate', - request_serializer=video_stitcher_service.UpdateSlateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_slate'] - - @property - def delete_slate(self) -> Callable[ - [video_stitcher_service.DeleteSlateRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete slate method over gRPC. - - Deletes the specified slate. - - Returns: - Callable[[~.DeleteSlateRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_slate' not in self._stubs: - self._stubs['delete_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteSlate', - request_serializer=video_stitcher_service.DeleteSlateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_slate'] - - @property - def create_live_session(self) -> Callable[ - [video_stitcher_service.CreateLiveSessionRequest], - sessions.LiveSession]: - r"""Return a callable for the create live session method over gRPC. - - Creates a new live session. - - Returns: - Callable[[~.CreateLiveSessionRequest], - ~.LiveSession]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_session' not in self._stubs: - self._stubs['create_live_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveSession', - request_serializer=video_stitcher_service.CreateLiveSessionRequest.serialize, - response_deserializer=sessions.LiveSession.deserialize, - ) - return self._stubs['create_live_session'] - - @property - def get_live_session(self) -> Callable[ - [video_stitcher_service.GetLiveSessionRequest], - sessions.LiveSession]: - r"""Return a callable for the get live session method over gRPC. - - Returns the details for the specified live session. - - Returns: - Callable[[~.GetLiveSessionRequest], - ~.LiveSession]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_session' not in self._stubs: - self._stubs['get_live_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveSession', - request_serializer=video_stitcher_service.GetLiveSessionRequest.serialize, - response_deserializer=sessions.LiveSession.deserialize, - ) - return self._stubs['get_live_session'] - - @property - def create_live_config(self) -> Callable[ - [video_stitcher_service.CreateLiveConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the create live config method over gRPC. - - Registers the live config with the provided unique ID - in the specified region. - - Returns: - Callable[[~.CreateLiveConfigRequest], - ~.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_live_config' not in self._stubs: - self._stubs['create_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveConfig', - request_serializer=video_stitcher_service.CreateLiveConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_live_config'] - - @property - def list_live_configs(self) -> Callable[ - [video_stitcher_service.ListLiveConfigsRequest], - video_stitcher_service.ListLiveConfigsResponse]: - r"""Return a callable for the list live configs method over gRPC. - - Lists all live configs managed by the Video Stitcher - that belong to the specified project and region. - - Returns: - Callable[[~.ListLiveConfigsRequest], - ~.ListLiveConfigsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_configs' not in self._stubs: - self._stubs['list_live_configs'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveConfigs', - request_serializer=video_stitcher_service.ListLiveConfigsRequest.serialize, - response_deserializer=video_stitcher_service.ListLiveConfigsResponse.deserialize, - ) - return self._stubs['list_live_configs'] - - @property - def get_live_config(self) -> Callable[ - [video_stitcher_service.GetLiveConfigRequest], - live_configs.LiveConfig]: - r"""Return a callable for the get live config method over gRPC. - - Returns the specified live config managed by the - Video Stitcher service. - - Returns: - Callable[[~.GetLiveConfigRequest], - ~.LiveConfig]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_config' not in self._stubs: - self._stubs['get_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveConfig', - request_serializer=video_stitcher_service.GetLiveConfigRequest.serialize, - response_deserializer=live_configs.LiveConfig.deserialize, - ) - return self._stubs['get_live_config'] - - @property - def delete_live_config(self) -> Callable[ - [video_stitcher_service.DeleteLiveConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete live config method over gRPC. - - Deletes the specified live config. - - Returns: - Callable[[~.DeleteLiveConfigRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_live_config' not in self._stubs: - self._stubs['delete_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteLiveConfig', - request_serializer=video_stitcher_service.DeleteLiveConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_live_config'] - - @property - def update_live_config(self) -> Callable[ - [video_stitcher_service.UpdateLiveConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the update live config method over gRPC. - - Updates the specified LiveConfig. Only update fields - specified in the call method body. - - Returns: - Callable[[~.UpdateLiveConfigRequest], - ~.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_live_config' not in self._stubs: - self._stubs['update_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateLiveConfig', - request_serializer=video_stitcher_service.UpdateLiveConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_live_config'] - - @property - def create_vod_config(self) -> Callable[ - [video_stitcher_service.CreateVodConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the create vod config method over gRPC. - - Registers the VOD config with the provided unique ID - in the specified region. - - Returns: - Callable[[~.CreateVodConfigRequest], - ~.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_vod_config' not in self._stubs: - self._stubs['create_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodConfig', - request_serializer=video_stitcher_service.CreateVodConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_vod_config'] - - @property - def list_vod_configs(self) -> Callable[ - [video_stitcher_service.ListVodConfigsRequest], - video_stitcher_service.ListVodConfigsResponse]: - r"""Return a callable for the list vod configs method over gRPC. - - Lists all VOD configs managed by the Video Stitcher - API that belong to the specified project and region. - - Returns: - Callable[[~.ListVodConfigsRequest], - ~.ListVodConfigsResponse]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_configs' not in self._stubs: - self._stubs['list_vod_configs'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodConfigs', - request_serializer=video_stitcher_service.ListVodConfigsRequest.serialize, - response_deserializer=video_stitcher_service.ListVodConfigsResponse.deserialize, - ) - return self._stubs['list_vod_configs'] - - @property - def get_vod_config(self) -> Callable[ - [video_stitcher_service.GetVodConfigRequest], - vod_configs.VodConfig]: - r"""Return a callable for the get vod config method over gRPC. - - Returns the specified VOD config managed by the Video - Stitcher API service. - - Returns: - Callable[[~.GetVodConfigRequest], - ~.VodConfig]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_config' not in self._stubs: - self._stubs['get_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodConfig', - request_serializer=video_stitcher_service.GetVodConfigRequest.serialize, - response_deserializer=vod_configs.VodConfig.deserialize, - ) - return self._stubs['get_vod_config'] - - @property - def delete_vod_config(self) -> Callable[ - [video_stitcher_service.DeleteVodConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the delete vod config method over gRPC. - - Deletes the specified VOD config. - - Returns: - Callable[[~.DeleteVodConfigRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_vod_config' not in self._stubs: - self._stubs['delete_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteVodConfig', - request_serializer=video_stitcher_service.DeleteVodConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_vod_config'] - - @property - def update_vod_config(self) -> Callable[ - [video_stitcher_service.UpdateVodConfigRequest], - operations_pb2.Operation]: - r"""Return a callable for the update vod config method over gRPC. - - Updates the specified VOD config. Only update fields - specified in the call method body. - - Returns: - Callable[[~.UpdateVodConfigRequest], - ~.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_vod_config' not in self._stubs: - self._stubs['update_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateVodConfig', - request_serializer=video_stitcher_service.UpdateVodConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_vod_config'] - - def close(self): - self._logged_channel.close() - - @property - def delete_operation( - self, - ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: - r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/DeleteOperation", - request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["delete_operation"] - - @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._logged_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._logged_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._logged_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'VideoStitcherServiceGrpcTransport', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py deleted file mode 100644 index f94216db29d5..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/grpc_asyncio.py +++ /dev/null @@ -1,1408 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 inspect -import json -import pickle -import logging as std_logging -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 exceptions as core_exceptions -from google.api_core import retry_async as retries -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 -from google.protobuf.json_format import MessageToJson -import google.protobuf.message - -import grpc # type: ignore -import proto # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs -from google.longrunning import operations_pb2 # type: ignore -from .base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO -from .grpc import VideoStitcherServiceGrpcTransport - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = std_logging.getLogger(__name__) - - -class _LoggingClientAIOInterceptor(grpc.aio.UnaryUnaryClientInterceptor): # pragma: NO COVER - async def intercept_unary_unary(self, continuation, client_call_details, request): - logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG) - if logging_enabled: # pragma: NO COVER - request_metadata = client_call_details.metadata - if isinstance(request, proto.Message): - request_payload = type(request).to_json(request) - elif isinstance(request, google.protobuf.message.Message): - request_payload = MessageToJson(request) - else: - request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" - - request_metadata = { - key: value.decode("utf-8") if isinstance(value, bytes) else value - for key, value in request_metadata - } - grpc_request = { - "payload": request_payload, - "requestMethod": "grpc", - "metadata": dict(request_metadata), - } - _LOGGER.debug( - f"Sending request for {client_call_details.method}", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": str(client_call_details.method), - "request": grpc_request, - "metadata": grpc_request["metadata"], - }, - ) - response = await continuation(client_call_details, request) - if logging_enabled: # pragma: NO COVER - response_metadata = await response.trailing_metadata() - # Convert gRPC metadata `` to list of tuples - metadata = dict([(k, str(v)) for k, v in response_metadata]) if response_metadata else None - result = await response - if isinstance(result, proto.Message): - response_payload = type(result).to_json(result) - elif isinstance(result, google.protobuf.message.Message): - response_payload = MessageToJson(result) - else: - response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" - grpc_response = { - "payload": response_payload, - "metadata": metadata, - "status": "OK", - } - _LOGGER.debug( - f"Received response to rpc {client_call_details.method}.", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": str(client_call_details.method), - "response": grpc_response, - "metadata": grpc_response["metadata"], - }, - ) - return response - - -class VideoStitcherServiceGrpcAsyncIOTransport(VideoStitcherServiceTransport): - """gRPC AsyncIO backend transport for VideoStitcherService. - - Video-On-Demand content stitching API allows you to insert - ads into (VoD) video on demand files. You will be able to render - custom scrubber bars with highlighted ads, enforce ad policies, - allow seamless playback and tracking on native players and - monetize content with any standard VMAP compliant ad server. - - 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 = 'videostitcher.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`. - 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 = 'videostitcher.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[Union[aio.Channel, Callable[..., 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 (default: 'videostitcher.googleapis.com'). - 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 a ``channel`` instance 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 a ``channel`` instance 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[Union[aio.Channel, Callable[..., aio.Channel]]]): - A ``Channel`` instance through which to make calls, or a Callable - that constructs and returns one. If set to None, ``self.create_channel`` - is used to create the channel. If a Callable is given, it will be called - with the same arguments as used in ``self.create_channel``. - 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 a ``channel`` instance 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 a ``channel`` instance 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 isinstance(channel, aio.Channel): - # Ignore credentials if a channel was passed. - credentials = None - self._ignore_credentials = True - # 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: - # initialize with the provided callable or the default channel - channel_init = channel or type(self).create_channel - self._grpc_channel = channel_init( - 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), - ], - ) - - self._interceptor = _LoggingClientAIOInterceptor() - self._grpc_channel._unary_unary_interceptors.append(self._interceptor) - self._logged_channel = self._grpc_channel - self._wrap_with_kind = "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters - # Wrap messages. This must be done after self._logged_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._logged_channel - ) - - # Return the client from cache. - return self._operations_client - - @property - def create_cdn_key(self) -> Callable[ - [video_stitcher_service.CreateCdnKeyRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create cdn key method over gRPC. - - Creates a new CDN key. - - Returns: - Callable[[~.CreateCdnKeyRequest], - 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_cdn_key' not in self._stubs: - self._stubs['create_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateCdnKey', - request_serializer=video_stitcher_service.CreateCdnKeyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_cdn_key'] - - @property - def list_cdn_keys(self) -> Callable[ - [video_stitcher_service.ListCdnKeysRequest], - Awaitable[video_stitcher_service.ListCdnKeysResponse]]: - r"""Return a callable for the list cdn keys method over gRPC. - - Lists all CDN keys in the specified project and - location. - - Returns: - Callable[[~.ListCdnKeysRequest], - Awaitable[~.ListCdnKeysResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_cdn_keys' not in self._stubs: - self._stubs['list_cdn_keys'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListCdnKeys', - request_serializer=video_stitcher_service.ListCdnKeysRequest.serialize, - response_deserializer=video_stitcher_service.ListCdnKeysResponse.deserialize, - ) - return self._stubs['list_cdn_keys'] - - @property - def get_cdn_key(self) -> Callable[ - [video_stitcher_service.GetCdnKeyRequest], - Awaitable[cdn_keys.CdnKey]]: - r"""Return a callable for the get cdn key method over gRPC. - - Returns the specified CDN key. - - Returns: - Callable[[~.GetCdnKeyRequest], - Awaitable[~.CdnKey]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_cdn_key' not in self._stubs: - self._stubs['get_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetCdnKey', - request_serializer=video_stitcher_service.GetCdnKeyRequest.serialize, - response_deserializer=cdn_keys.CdnKey.deserialize, - ) - return self._stubs['get_cdn_key'] - - @property - def delete_cdn_key(self) -> Callable[ - [video_stitcher_service.DeleteCdnKeyRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete cdn key method over gRPC. - - Deletes the specified CDN key. - - Returns: - Callable[[~.DeleteCdnKeyRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_cdn_key' not in self._stubs: - self._stubs['delete_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteCdnKey', - request_serializer=video_stitcher_service.DeleteCdnKeyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_cdn_key'] - - @property - def update_cdn_key(self) -> Callable[ - [video_stitcher_service.UpdateCdnKeyRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update cdn key method over gRPC. - - Updates the specified CDN key. Only update fields - specified in the call method body. - - Returns: - Callable[[~.UpdateCdnKeyRequest], - 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_cdn_key' not in self._stubs: - self._stubs['update_cdn_key'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateCdnKey', - request_serializer=video_stitcher_service.UpdateCdnKeyRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_cdn_key'] - - @property - def create_vod_session(self) -> Callable[ - [video_stitcher_service.CreateVodSessionRequest], - Awaitable[sessions.VodSession]]: - r"""Return a callable for the create vod session method over gRPC. - - Creates a client side playback VOD session and - returns the full tracking and playback metadata of the - session. - - Returns: - Callable[[~.CreateVodSessionRequest], - Awaitable[~.VodSession]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_session' not in self._stubs: - self._stubs['create_vod_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodSession', - request_serializer=video_stitcher_service.CreateVodSessionRequest.serialize, - response_deserializer=sessions.VodSession.deserialize, - ) - return self._stubs['create_vod_session'] - - @property - def get_vod_session(self) -> Callable[ - [video_stitcher_service.GetVodSessionRequest], - Awaitable[sessions.VodSession]]: - r"""Return a callable for the get vod session method over gRPC. - - Returns the full tracking, playback metadata, and - relevant ad-ops logs for the specified VOD session. - - Returns: - Callable[[~.GetVodSessionRequest], - Awaitable[~.VodSession]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_session' not in self._stubs: - self._stubs['get_vod_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodSession', - request_serializer=video_stitcher_service.GetVodSessionRequest.serialize, - response_deserializer=sessions.VodSession.deserialize, - ) - return self._stubs['get_vod_session'] - - @property - def list_vod_stitch_details(self) -> Callable[ - [video_stitcher_service.ListVodStitchDetailsRequest], - Awaitable[video_stitcher_service.ListVodStitchDetailsResponse]]: - r"""Return a callable for the list vod stitch details method over gRPC. - - Returns a list of detailed stitching information of - the specified VOD session. - - Returns: - Callable[[~.ListVodStitchDetailsRequest], - Awaitable[~.ListVodStitchDetailsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_stitch_details' not in self._stubs: - self._stubs['list_vod_stitch_details'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodStitchDetails', - request_serializer=video_stitcher_service.ListVodStitchDetailsRequest.serialize, - response_deserializer=video_stitcher_service.ListVodStitchDetailsResponse.deserialize, - ) - return self._stubs['list_vod_stitch_details'] - - @property - def get_vod_stitch_detail(self) -> Callable[ - [video_stitcher_service.GetVodStitchDetailRequest], - Awaitable[stitch_details.VodStitchDetail]]: - r"""Return a callable for the get vod stitch detail method over gRPC. - - Returns the specified stitching information for the - specified VOD session. - - Returns: - Callable[[~.GetVodStitchDetailRequest], - Awaitable[~.VodStitchDetail]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_stitch_detail' not in self._stubs: - self._stubs['get_vod_stitch_detail'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodStitchDetail', - request_serializer=video_stitcher_service.GetVodStitchDetailRequest.serialize, - response_deserializer=stitch_details.VodStitchDetail.deserialize, - ) - return self._stubs['get_vod_stitch_detail'] - - @property - def list_vod_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListVodAdTagDetailsRequest], - Awaitable[video_stitcher_service.ListVodAdTagDetailsResponse]]: - r"""Return a callable for the list vod ad tag details method over gRPC. - - Return the list of ad tag details for the specified - VOD session. - - Returns: - Callable[[~.ListVodAdTagDetailsRequest], - Awaitable[~.ListVodAdTagDetailsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_ad_tag_details' not in self._stubs: - self._stubs['list_vod_ad_tag_details'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodAdTagDetails', - request_serializer=video_stitcher_service.ListVodAdTagDetailsRequest.serialize, - response_deserializer=video_stitcher_service.ListVodAdTagDetailsResponse.deserialize, - ) - return self._stubs['list_vod_ad_tag_details'] - - @property - def get_vod_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetVodAdTagDetailRequest], - Awaitable[ad_tag_details.VodAdTagDetail]]: - r"""Return a callable for the get vod ad tag detail method over gRPC. - - Returns the specified ad tag detail for the specified - VOD session. - - Returns: - Callable[[~.GetVodAdTagDetailRequest], - Awaitable[~.VodAdTagDetail]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_ad_tag_detail' not in self._stubs: - self._stubs['get_vod_ad_tag_detail'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodAdTagDetail', - request_serializer=video_stitcher_service.GetVodAdTagDetailRequest.serialize, - response_deserializer=ad_tag_details.VodAdTagDetail.deserialize, - ) - return self._stubs['get_vod_ad_tag_detail'] - - @property - def list_live_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListLiveAdTagDetailsRequest], - Awaitable[video_stitcher_service.ListLiveAdTagDetailsResponse]]: - r"""Return a callable for the list live ad tag details method over gRPC. - - Return the list of ad tag details for the specified - live session. - - Returns: - Callable[[~.ListLiveAdTagDetailsRequest], - Awaitable[~.ListLiveAdTagDetailsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_ad_tag_details' not in self._stubs: - self._stubs['list_live_ad_tag_details'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveAdTagDetails', - request_serializer=video_stitcher_service.ListLiveAdTagDetailsRequest.serialize, - response_deserializer=video_stitcher_service.ListLiveAdTagDetailsResponse.deserialize, - ) - return self._stubs['list_live_ad_tag_details'] - - @property - def get_live_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetLiveAdTagDetailRequest], - Awaitable[ad_tag_details.LiveAdTagDetail]]: - r"""Return a callable for the get live ad tag detail method over gRPC. - - Returns the specified ad tag detail for the specified - live session. - - Returns: - Callable[[~.GetLiveAdTagDetailRequest], - Awaitable[~.LiveAdTagDetail]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_ad_tag_detail' not in self._stubs: - self._stubs['get_live_ad_tag_detail'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveAdTagDetail', - request_serializer=video_stitcher_service.GetLiveAdTagDetailRequest.serialize, - response_deserializer=ad_tag_details.LiveAdTagDetail.deserialize, - ) - return self._stubs['get_live_ad_tag_detail'] - - @property - def create_slate(self) -> Callable[ - [video_stitcher_service.CreateSlateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create slate method over gRPC. - - Creates a slate. - - Returns: - Callable[[~.CreateSlateRequest], - 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_slate' not in self._stubs: - self._stubs['create_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateSlate', - request_serializer=video_stitcher_service.CreateSlateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_slate'] - - @property - def list_slates(self) -> Callable[ - [video_stitcher_service.ListSlatesRequest], - Awaitable[video_stitcher_service.ListSlatesResponse]]: - r"""Return a callable for the list slates method over gRPC. - - Lists all slates in the specified project and - location. - - Returns: - Callable[[~.ListSlatesRequest], - Awaitable[~.ListSlatesResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_slates' not in self._stubs: - self._stubs['list_slates'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListSlates', - request_serializer=video_stitcher_service.ListSlatesRequest.serialize, - response_deserializer=video_stitcher_service.ListSlatesResponse.deserialize, - ) - return self._stubs['list_slates'] - - @property - def get_slate(self) -> Callable[ - [video_stitcher_service.GetSlateRequest], - Awaitable[slates.Slate]]: - r"""Return a callable for the get slate method over gRPC. - - Returns the specified slate. - - Returns: - Callable[[~.GetSlateRequest], - Awaitable[~.Slate]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_slate' not in self._stubs: - self._stubs['get_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetSlate', - request_serializer=video_stitcher_service.GetSlateRequest.serialize, - response_deserializer=slates.Slate.deserialize, - ) - return self._stubs['get_slate'] - - @property - def update_slate(self) -> Callable[ - [video_stitcher_service.UpdateSlateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update slate method over gRPC. - - Updates the specified slate. - - Returns: - Callable[[~.UpdateSlateRequest], - 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_slate' not in self._stubs: - self._stubs['update_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateSlate', - request_serializer=video_stitcher_service.UpdateSlateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_slate'] - - @property - def delete_slate(self) -> Callable[ - [video_stitcher_service.DeleteSlateRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete slate method over gRPC. - - Deletes the specified slate. - - Returns: - Callable[[~.DeleteSlateRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_slate' not in self._stubs: - self._stubs['delete_slate'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteSlate', - request_serializer=video_stitcher_service.DeleteSlateRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_slate'] - - @property - def create_live_session(self) -> Callable[ - [video_stitcher_service.CreateLiveSessionRequest], - Awaitable[sessions.LiveSession]]: - r"""Return a callable for the create live session method over gRPC. - - Creates a new live session. - - Returns: - Callable[[~.CreateLiveSessionRequest], - Awaitable[~.LiveSession]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_session' not in self._stubs: - self._stubs['create_live_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveSession', - request_serializer=video_stitcher_service.CreateLiveSessionRequest.serialize, - response_deserializer=sessions.LiveSession.deserialize, - ) - return self._stubs['create_live_session'] - - @property - def get_live_session(self) -> Callable[ - [video_stitcher_service.GetLiveSessionRequest], - Awaitable[sessions.LiveSession]]: - r"""Return a callable for the get live session method over gRPC. - - Returns the details for the specified live session. - - Returns: - Callable[[~.GetLiveSessionRequest], - Awaitable[~.LiveSession]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_session' not in self._stubs: - self._stubs['get_live_session'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveSession', - request_serializer=video_stitcher_service.GetLiveSessionRequest.serialize, - response_deserializer=sessions.LiveSession.deserialize, - ) - return self._stubs['get_live_session'] - - @property - def create_live_config(self) -> Callable[ - [video_stitcher_service.CreateLiveConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create live config method over gRPC. - - Registers the live config with the provided unique ID - in the specified region. - - Returns: - Callable[[~.CreateLiveConfigRequest], - 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_live_config' not in self._stubs: - self._stubs['create_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateLiveConfig', - request_serializer=video_stitcher_service.CreateLiveConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_live_config'] - - @property - def list_live_configs(self) -> Callable[ - [video_stitcher_service.ListLiveConfigsRequest], - Awaitable[video_stitcher_service.ListLiveConfigsResponse]]: - r"""Return a callable for the list live configs method over gRPC. - - Lists all live configs managed by the Video Stitcher - that belong to the specified project and region. - - Returns: - Callable[[~.ListLiveConfigsRequest], - Awaitable[~.ListLiveConfigsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_configs' not in self._stubs: - self._stubs['list_live_configs'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListLiveConfigs', - request_serializer=video_stitcher_service.ListLiveConfigsRequest.serialize, - response_deserializer=video_stitcher_service.ListLiveConfigsResponse.deserialize, - ) - return self._stubs['list_live_configs'] - - @property - def get_live_config(self) -> Callable[ - [video_stitcher_service.GetLiveConfigRequest], - Awaitable[live_configs.LiveConfig]]: - r"""Return a callable for the get live config method over gRPC. - - Returns the specified live config managed by the - Video Stitcher service. - - Returns: - Callable[[~.GetLiveConfigRequest], - Awaitable[~.LiveConfig]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_live_config' not in self._stubs: - self._stubs['get_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetLiveConfig', - request_serializer=video_stitcher_service.GetLiveConfigRequest.serialize, - response_deserializer=live_configs.LiveConfig.deserialize, - ) - return self._stubs['get_live_config'] - - @property - def delete_live_config(self) -> Callable[ - [video_stitcher_service.DeleteLiveConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete live config method over gRPC. - - Deletes the specified live config. - - Returns: - Callable[[~.DeleteLiveConfigRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_live_config' not in self._stubs: - self._stubs['delete_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteLiveConfig', - request_serializer=video_stitcher_service.DeleteLiveConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_live_config'] - - @property - def update_live_config(self) -> Callable[ - [video_stitcher_service.UpdateLiveConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update live config method over gRPC. - - Updates the specified LiveConfig. Only update fields - specified in the call method body. - - Returns: - Callable[[~.UpdateLiveConfigRequest], - 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_live_config' not in self._stubs: - self._stubs['update_live_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateLiveConfig', - request_serializer=video_stitcher_service.UpdateLiveConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_live_config'] - - @property - def create_vod_config(self) -> Callable[ - [video_stitcher_service.CreateVodConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the create vod config method over gRPC. - - Registers the VOD config with the provided unique ID - in the specified region. - - Returns: - Callable[[~.CreateVodConfigRequest], - 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_vod_config' not in self._stubs: - self._stubs['create_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/CreateVodConfig', - request_serializer=video_stitcher_service.CreateVodConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['create_vod_config'] - - @property - def list_vod_configs(self) -> Callable[ - [video_stitcher_service.ListVodConfigsRequest], - Awaitable[video_stitcher_service.ListVodConfigsResponse]]: - r"""Return a callable for the list vod configs method over gRPC. - - Lists all VOD configs managed by the Video Stitcher - API that belong to the specified project and region. - - Returns: - Callable[[~.ListVodConfigsRequest], - Awaitable[~.ListVodConfigsResponse]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_configs' not in self._stubs: - self._stubs['list_vod_configs'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/ListVodConfigs', - request_serializer=video_stitcher_service.ListVodConfigsRequest.serialize, - response_deserializer=video_stitcher_service.ListVodConfigsResponse.deserialize, - ) - return self._stubs['list_vod_configs'] - - @property - def get_vod_config(self) -> Callable[ - [video_stitcher_service.GetVodConfigRequest], - Awaitable[vod_configs.VodConfig]]: - r"""Return a callable for the get vod config method over gRPC. - - Returns the specified VOD config managed by the Video - Stitcher API service. - - Returns: - Callable[[~.GetVodConfigRequest], - Awaitable[~.VodConfig]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-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_vod_config' not in self._stubs: - self._stubs['get_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/GetVodConfig', - request_serializer=video_stitcher_service.GetVodConfigRequest.serialize, - response_deserializer=vod_configs.VodConfig.deserialize, - ) - return self._stubs['get_vod_config'] - - @property - def delete_vod_config(self) -> Callable[ - [video_stitcher_service.DeleteVodConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the delete vod config method over gRPC. - - Deletes the specified VOD config. - - Returns: - Callable[[~.DeleteVodConfigRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if 'delete_vod_config' not in self._stubs: - self._stubs['delete_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/DeleteVodConfig', - request_serializer=video_stitcher_service.DeleteVodConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['delete_vod_config'] - - @property - def update_vod_config(self) -> Callable[ - [video_stitcher_service.UpdateVodConfigRequest], - Awaitable[operations_pb2.Operation]]: - r"""Return a callable for the update vod config method over gRPC. - - Updates the specified VOD config. Only update fields - specified in the call method body. - - Returns: - Callable[[~.UpdateVodConfigRequest], - 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_vod_config' not in self._stubs: - self._stubs['update_vod_config'] = self._logged_channel.unary_unary( - '/google.cloud.video.stitcher.v1.VideoStitcherService/UpdateVodConfig', - request_serializer=video_stitcher_service.UpdateVodConfigRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs['update_vod_config'] - - def _prep_wrapped_messages(self, client_info): - """ Precompute the wrapped methods, overriding the base class method to use async wrappers.""" - self._wrapped_methods = { - self.create_cdn_key: self._wrap_method( - self.create_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.list_cdn_keys: self._wrap_method( - self.list_cdn_keys, - default_timeout=60.0, - client_info=client_info, - ), - self.get_cdn_key: self._wrap_method( - self.get_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_cdn_key: self._wrap_method( - self.delete_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.update_cdn_key: self._wrap_method( - self.update_cdn_key, - default_timeout=60.0, - client_info=client_info, - ), - self.create_vod_session: self._wrap_method( - self.create_vod_session, - default_timeout=60.0, - client_info=client_info, - ), - self.get_vod_session: self._wrap_method( - self.get_vod_session, - default_timeout=60.0, - client_info=client_info, - ), - self.list_vod_stitch_details: self._wrap_method( - self.list_vod_stitch_details, - default_timeout=60.0, - client_info=client_info, - ), - self.get_vod_stitch_detail: self._wrap_method( - self.get_vod_stitch_detail, - default_timeout=60.0, - client_info=client_info, - ), - self.list_vod_ad_tag_details: self._wrap_method( - self.list_vod_ad_tag_details, - default_timeout=60.0, - client_info=client_info, - ), - self.get_vod_ad_tag_detail: self._wrap_method( - self.get_vod_ad_tag_detail, - default_timeout=60.0, - client_info=client_info, - ), - self.list_live_ad_tag_details: self._wrap_method( - self.list_live_ad_tag_details, - default_timeout=60.0, - client_info=client_info, - ), - self.get_live_ad_tag_detail: self._wrap_method( - self.get_live_ad_tag_detail, - default_timeout=60.0, - client_info=client_info, - ), - self.create_slate: self._wrap_method( - self.create_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.list_slates: self._wrap_method( - self.list_slates, - default_timeout=60.0, - client_info=client_info, - ), - self.get_slate: self._wrap_method( - self.get_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.update_slate: self._wrap_method( - self.update_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_slate: self._wrap_method( - self.delete_slate, - default_timeout=60.0, - client_info=client_info, - ), - self.create_live_session: self._wrap_method( - self.create_live_session, - default_timeout=60.0, - client_info=client_info, - ), - self.get_live_session: self._wrap_method( - self.get_live_session, - default_timeout=60.0, - client_info=client_info, - ), - self.create_live_config: self._wrap_method( - self.create_live_config, - default_timeout=60.0, - client_info=client_info, - ), - self.list_live_configs: self._wrap_method( - self.list_live_configs, - default_timeout=60.0, - client_info=client_info, - ), - self.get_live_config: self._wrap_method( - self.get_live_config, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_live_config: self._wrap_method( - self.delete_live_config, - default_timeout=60.0, - client_info=client_info, - ), - self.update_live_config: self._wrap_method( - self.update_live_config, - default_timeout=None, - client_info=client_info, - ), - self.create_vod_config: self._wrap_method( - self.create_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.list_vod_configs: self._wrap_method( - self.list_vod_configs, - default_timeout=None, - client_info=client_info, - ), - self.get_vod_config: self._wrap_method( - self.get_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.delete_vod_config: self._wrap_method( - self.delete_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.update_vod_config: self._wrap_method( - self.update_vod_config, - default_timeout=None, - client_info=client_info, - ), - self.cancel_operation: self._wrap_method( - self.cancel_operation, - default_timeout=None, - client_info=client_info, - ), - self.delete_operation: self._wrap_method( - self.delete_operation, - default_timeout=None, - client_info=client_info, - ), - self.get_operation: self._wrap_method( - self.get_operation, - default_timeout=None, - client_info=client_info, - ), - self.list_operations: self._wrap_method( - self.list_operations, - default_timeout=None, - client_info=client_info, - ), - } - - def _wrap_method(self, func, *args, **kwargs): - if self._wrap_with_kind: # pragma: NO COVER - kwargs["kind"] = self.kind - return gapic_v1.method_async.wrap_method(func, *args, **kwargs) - - def close(self): - return self._logged_channel.close() - - @property - def kind(self) -> str: - return "grpc_asyncio" - - @property - def delete_operation( - self, - ) -> Callable[[operations_pb2.DeleteOperationRequest], None]: - r"""Return a callable for the delete_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 "delete_operation" not in self._stubs: - self._stubs["delete_operation"] = self._logged_channel.unary_unary( - "/google.longrunning.Operations/DeleteOperation", - request_serializer=operations_pb2.DeleteOperationRequest.SerializeToString, - response_deserializer=None, - ) - return self._stubs["delete_operation"] - - @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._logged_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._logged_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._logged_channel.unary_unary( - "/google.longrunning.Operations/ListOperations", - request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, - response_deserializer=operations_pb2.ListOperationsResponse.FromString, - ) - return self._stubs["list_operations"] - - -__all__ = ( - 'VideoStitcherServiceGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py deleted file mode 100644 index 34ecf213f3ae..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py +++ /dev/null @@ -1,6004 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 logging -import json # type: ignore - -from google.auth.transport.requests import AuthorizedSession # 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 gapic_v1 -import google.protobuf - -from google.protobuf import json_format -from google.api_core import operations_v1 - -from requests import __version__ as requests_version -import dataclasses -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings - - -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs -from google.longrunning import operations_pb2 # type: ignore - - -from .rest_base import _BaseVideoStitcherServiceRestTransport -from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object, None] # type: ignore - -try: - from google.api_core import client_logging # type: ignore - CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER -except ImportError: # pragma: NO COVER - CLIENT_LOGGING_SUPPORTED = False - -_LOGGER = logging.getLogger(__name__) - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, - grpc_version=None, - rest_version=f"requests@{requests_version}", -) - -if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER - DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ - - -class VideoStitcherServiceRestInterceptor: - """Interceptor for VideoStitcherService. - - 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 VideoStitcherServiceRestTransport. - - .. code-block:: python - class MyCustomVideoStitcherServiceInterceptor(VideoStitcherServiceRestInterceptor): - def pre_create_cdn_key(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_cdn_key(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_live_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_live_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_live_session(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_live_session(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_slate(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_slate(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_vod_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_vod_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_vod_session(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_vod_session(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_cdn_key(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_cdn_key(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_live_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_live_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_slate(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_slate(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_vod_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_delete_vod_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_cdn_key(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_cdn_key(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_live_ad_tag_detail(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_live_ad_tag_detail(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_live_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_live_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_live_session(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_live_session(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_slate(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_slate(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_vod_ad_tag_detail(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_vod_ad_tag_detail(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_vod_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_vod_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_vod_session(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_vod_session(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_vod_stitch_detail(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_vod_stitch_detail(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_cdn_keys(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_cdn_keys(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_live_ad_tag_details(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_live_ad_tag_details(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_live_configs(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_live_configs(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_slates(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_slates(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_vod_ad_tag_details(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_vod_ad_tag_details(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_vod_configs(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_vod_configs(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_vod_stitch_details(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_vod_stitch_details(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_cdn_key(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_cdn_key(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_live_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_live_config(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_slate(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_slate(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_vod_config(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_vod_config(self, response): - logging.log(f"Received response: {response}") - return response - - transport = VideoStitcherServiceRestTransport(interceptor=MyCustomVideoStitcherServiceInterceptor()) - client = VideoStitcherServiceClient(transport=transport) - - - """ - def pre_create_cdn_key(self, request: video_stitcher_service.CreateCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_cdn_key - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_create_cdn_key(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_cdn_key - - DEPRECATED. Please use the `post_create_cdn_key_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_create_cdn_key` interceptor runs - before the `post_create_cdn_key_with_metadata` interceptor. - """ - return response - - def post_create_cdn_key_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_cdn_key - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_create_cdn_key_with_metadata` - interceptor in new development instead of the `post_create_cdn_key` interceptor. - When both interceptors are used, this `post_create_cdn_key_with_metadata` interceptor runs after the - `post_create_cdn_key` interceptor. The (possibly modified) response returned by - `post_create_cdn_key` will be passed to - `post_create_cdn_key_with_metadata`. - """ - return response, metadata - - def pre_create_live_config(self, request: video_stitcher_service.CreateLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_live_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_create_live_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_live_config - - DEPRECATED. Please use the `post_create_live_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_create_live_config` interceptor runs - before the `post_create_live_config_with_metadata` interceptor. - """ - return response - - def post_create_live_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_live_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_create_live_config_with_metadata` - interceptor in new development instead of the `post_create_live_config` interceptor. - When both interceptors are used, this `post_create_live_config_with_metadata` interceptor runs after the - `post_create_live_config` interceptor. The (possibly modified) response returned by - `post_create_live_config` will be passed to - `post_create_live_config_with_metadata`. - """ - return response, metadata - - def pre_create_live_session(self, request: video_stitcher_service.CreateLiveSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateLiveSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_live_session - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_create_live_session(self, response: sessions.LiveSession) -> sessions.LiveSession: - """Post-rpc interceptor for create_live_session - - DEPRECATED. Please use the `post_create_live_session_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_create_live_session` interceptor runs - before the `post_create_live_session_with_metadata` interceptor. - """ - return response - - def post_create_live_session_with_metadata(self, response: sessions.LiveSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.LiveSession, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_live_session - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_create_live_session_with_metadata` - interceptor in new development instead of the `post_create_live_session` interceptor. - When both interceptors are used, this `post_create_live_session_with_metadata` interceptor runs after the - `post_create_live_session` interceptor. The (possibly modified) response returned by - `post_create_live_session` will be passed to - `post_create_live_session_with_metadata`. - """ - return response, metadata - - def pre_create_slate(self, request: video_stitcher_service.CreateSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_slate - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_create_slate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_slate - - DEPRECATED. Please use the `post_create_slate_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_create_slate` interceptor runs - before the `post_create_slate_with_metadata` interceptor. - """ - return response - - def post_create_slate_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_slate - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_create_slate_with_metadata` - interceptor in new development instead of the `post_create_slate` interceptor. - When both interceptors are used, this `post_create_slate_with_metadata` interceptor runs after the - `post_create_slate` interceptor. The (possibly modified) response returned by - `post_create_slate` will be passed to - `post_create_slate_with_metadata`. - """ - return response, metadata - - def pre_create_vod_config(self, request: video_stitcher_service.CreateVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_vod_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_create_vod_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for create_vod_config - - DEPRECATED. Please use the `post_create_vod_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_create_vod_config` interceptor runs - before the `post_create_vod_config_with_metadata` interceptor. - """ - return response - - def post_create_vod_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_vod_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_create_vod_config_with_metadata` - interceptor in new development instead of the `post_create_vod_config` interceptor. - When both interceptors are used, this `post_create_vod_config_with_metadata` interceptor runs after the - `post_create_vod_config` interceptor. The (possibly modified) response returned by - `post_create_vod_config` will be passed to - `post_create_vod_config_with_metadata`. - """ - return response, metadata - - def pre_create_vod_session(self, request: video_stitcher_service.CreateVodSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.CreateVodSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for create_vod_session - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_create_vod_session(self, response: sessions.VodSession) -> sessions.VodSession: - """Post-rpc interceptor for create_vod_session - - DEPRECATED. Please use the `post_create_vod_session_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_create_vod_session` interceptor runs - before the `post_create_vod_session_with_metadata` interceptor. - """ - return response - - def post_create_vod_session_with_metadata(self, response: sessions.VodSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.VodSession, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for create_vod_session - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_create_vod_session_with_metadata` - interceptor in new development instead of the `post_create_vod_session` interceptor. - When both interceptors are used, this `post_create_vod_session_with_metadata` interceptor runs after the - `post_create_vod_session` interceptor. The (possibly modified) response returned by - `post_create_vod_session` will be passed to - `post_create_vod_session_with_metadata`. - """ - return response, metadata - - def pre_delete_cdn_key(self, request: video_stitcher_service.DeleteCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_cdn_key - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_delete_cdn_key(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_cdn_key - - DEPRECATED. Please use the `post_delete_cdn_key_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_delete_cdn_key` interceptor runs - before the `post_delete_cdn_key_with_metadata` interceptor. - """ - return response - - def post_delete_cdn_key_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_cdn_key - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_delete_cdn_key_with_metadata` - interceptor in new development instead of the `post_delete_cdn_key` interceptor. - When both interceptors are used, this `post_delete_cdn_key_with_metadata` interceptor runs after the - `post_delete_cdn_key` interceptor. The (possibly modified) response returned by - `post_delete_cdn_key` will be passed to - `post_delete_cdn_key_with_metadata`. - """ - return response, metadata - - def pre_delete_live_config(self, request: video_stitcher_service.DeleteLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_live_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_delete_live_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_live_config - - DEPRECATED. Please use the `post_delete_live_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_delete_live_config` interceptor runs - before the `post_delete_live_config_with_metadata` interceptor. - """ - return response - - def post_delete_live_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_live_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_delete_live_config_with_metadata` - interceptor in new development instead of the `post_delete_live_config` interceptor. - When both interceptors are used, this `post_delete_live_config_with_metadata` interceptor runs after the - `post_delete_live_config` interceptor. The (possibly modified) response returned by - `post_delete_live_config` will be passed to - `post_delete_live_config_with_metadata`. - """ - return response, metadata - - def pre_delete_slate(self, request: video_stitcher_service.DeleteSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_slate - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_delete_slate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_slate - - DEPRECATED. Please use the `post_delete_slate_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_delete_slate` interceptor runs - before the `post_delete_slate_with_metadata` interceptor. - """ - return response - - def post_delete_slate_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_slate - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_delete_slate_with_metadata` - interceptor in new development instead of the `post_delete_slate` interceptor. - When both interceptors are used, this `post_delete_slate_with_metadata` interceptor runs after the - `post_delete_slate` interceptor. The (possibly modified) response returned by - `post_delete_slate` will be passed to - `post_delete_slate_with_metadata`. - """ - return response, metadata - - def pre_delete_vod_config(self, request: video_stitcher_service.DeleteVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.DeleteVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_vod_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_delete_vod_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for delete_vod_config - - DEPRECATED. Please use the `post_delete_vod_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_delete_vod_config` interceptor runs - before the `post_delete_vod_config_with_metadata` interceptor. - """ - return response - - def post_delete_vod_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for delete_vod_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_delete_vod_config_with_metadata` - interceptor in new development instead of the `post_delete_vod_config` interceptor. - When both interceptors are used, this `post_delete_vod_config_with_metadata` interceptor runs after the - `post_delete_vod_config` interceptor. The (possibly modified) response returned by - `post_delete_vod_config` will be passed to - `post_delete_vod_config_with_metadata`. - """ - return response, metadata - - def pre_get_cdn_key(self, request: video_stitcher_service.GetCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_cdn_key - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_cdn_key(self, response: cdn_keys.CdnKey) -> cdn_keys.CdnKey: - """Post-rpc interceptor for get_cdn_key - - DEPRECATED. Please use the `post_get_cdn_key_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_cdn_key` interceptor runs - before the `post_get_cdn_key_with_metadata` interceptor. - """ - return response - - def post_get_cdn_key_with_metadata(self, response: cdn_keys.CdnKey, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[cdn_keys.CdnKey, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_cdn_key - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_cdn_key_with_metadata` - interceptor in new development instead of the `post_get_cdn_key` interceptor. - When both interceptors are used, this `post_get_cdn_key_with_metadata` interceptor runs after the - `post_get_cdn_key` interceptor. The (possibly modified) response returned by - `post_get_cdn_key` will be passed to - `post_get_cdn_key_with_metadata`. - """ - return response, metadata - - def pre_get_live_ad_tag_detail(self, request: video_stitcher_service.GetLiveAdTagDetailRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetLiveAdTagDetailRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_live_ad_tag_detail - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_live_ad_tag_detail(self, response: ad_tag_details.LiveAdTagDetail) -> ad_tag_details.LiveAdTagDetail: - """Post-rpc interceptor for get_live_ad_tag_detail - - DEPRECATED. Please use the `post_get_live_ad_tag_detail_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_live_ad_tag_detail` interceptor runs - before the `post_get_live_ad_tag_detail_with_metadata` interceptor. - """ - return response - - def post_get_live_ad_tag_detail_with_metadata(self, response: ad_tag_details.LiveAdTagDetail, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[ad_tag_details.LiveAdTagDetail, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_live_ad_tag_detail - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_live_ad_tag_detail_with_metadata` - interceptor in new development instead of the `post_get_live_ad_tag_detail` interceptor. - When both interceptors are used, this `post_get_live_ad_tag_detail_with_metadata` interceptor runs after the - `post_get_live_ad_tag_detail` interceptor. The (possibly modified) response returned by - `post_get_live_ad_tag_detail` will be passed to - `post_get_live_ad_tag_detail_with_metadata`. - """ - return response, metadata - - def pre_get_live_config(self, request: video_stitcher_service.GetLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_live_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_live_config(self, response: live_configs.LiveConfig) -> live_configs.LiveConfig: - """Post-rpc interceptor for get_live_config - - DEPRECATED. Please use the `post_get_live_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_live_config` interceptor runs - before the `post_get_live_config_with_metadata` interceptor. - """ - return response - - def post_get_live_config_with_metadata(self, response: live_configs.LiveConfig, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[live_configs.LiveConfig, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_live_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_live_config_with_metadata` - interceptor in new development instead of the `post_get_live_config` interceptor. - When both interceptors are used, this `post_get_live_config_with_metadata` interceptor runs after the - `post_get_live_config` interceptor. The (possibly modified) response returned by - `post_get_live_config` will be passed to - `post_get_live_config_with_metadata`. - """ - return response, metadata - - def pre_get_live_session(self, request: video_stitcher_service.GetLiveSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetLiveSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_live_session - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_live_session(self, response: sessions.LiveSession) -> sessions.LiveSession: - """Post-rpc interceptor for get_live_session - - DEPRECATED. Please use the `post_get_live_session_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_live_session` interceptor runs - before the `post_get_live_session_with_metadata` interceptor. - """ - return response - - def post_get_live_session_with_metadata(self, response: sessions.LiveSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.LiveSession, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_live_session - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_live_session_with_metadata` - interceptor in new development instead of the `post_get_live_session` interceptor. - When both interceptors are used, this `post_get_live_session_with_metadata` interceptor runs after the - `post_get_live_session` interceptor. The (possibly modified) response returned by - `post_get_live_session` will be passed to - `post_get_live_session_with_metadata`. - """ - return response, metadata - - def pre_get_slate(self, request: video_stitcher_service.GetSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_slate - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_slate(self, response: slates.Slate) -> slates.Slate: - """Post-rpc interceptor for get_slate - - DEPRECATED. Please use the `post_get_slate_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_slate` interceptor runs - before the `post_get_slate_with_metadata` interceptor. - """ - return response - - def post_get_slate_with_metadata(self, response: slates.Slate, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[slates.Slate, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_slate - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_slate_with_metadata` - interceptor in new development instead of the `post_get_slate` interceptor. - When both interceptors are used, this `post_get_slate_with_metadata` interceptor runs after the - `post_get_slate` interceptor. The (possibly modified) response returned by - `post_get_slate` will be passed to - `post_get_slate_with_metadata`. - """ - return response, metadata - - def pre_get_vod_ad_tag_detail(self, request: video_stitcher_service.GetVodAdTagDetailRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodAdTagDetailRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_vod_ad_tag_detail - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_vod_ad_tag_detail(self, response: ad_tag_details.VodAdTagDetail) -> ad_tag_details.VodAdTagDetail: - """Post-rpc interceptor for get_vod_ad_tag_detail - - DEPRECATED. Please use the `post_get_vod_ad_tag_detail_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_vod_ad_tag_detail` interceptor runs - before the `post_get_vod_ad_tag_detail_with_metadata` interceptor. - """ - return response - - def post_get_vod_ad_tag_detail_with_metadata(self, response: ad_tag_details.VodAdTagDetail, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[ad_tag_details.VodAdTagDetail, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_vod_ad_tag_detail - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_vod_ad_tag_detail_with_metadata` - interceptor in new development instead of the `post_get_vod_ad_tag_detail` interceptor. - When both interceptors are used, this `post_get_vod_ad_tag_detail_with_metadata` interceptor runs after the - `post_get_vod_ad_tag_detail` interceptor. The (possibly modified) response returned by - `post_get_vod_ad_tag_detail` will be passed to - `post_get_vod_ad_tag_detail_with_metadata`. - """ - return response, metadata - - def pre_get_vod_config(self, request: video_stitcher_service.GetVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_vod_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_vod_config(self, response: vod_configs.VodConfig) -> vod_configs.VodConfig: - """Post-rpc interceptor for get_vod_config - - DEPRECATED. Please use the `post_get_vod_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_vod_config` interceptor runs - before the `post_get_vod_config_with_metadata` interceptor. - """ - return response - - def post_get_vod_config_with_metadata(self, response: vod_configs.VodConfig, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[vod_configs.VodConfig, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_vod_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_vod_config_with_metadata` - interceptor in new development instead of the `post_get_vod_config` interceptor. - When both interceptors are used, this `post_get_vod_config_with_metadata` interceptor runs after the - `post_get_vod_config` interceptor. The (possibly modified) response returned by - `post_get_vod_config` will be passed to - `post_get_vod_config_with_metadata`. - """ - return response, metadata - - def pre_get_vod_session(self, request: video_stitcher_service.GetVodSessionRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodSessionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_vod_session - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_vod_session(self, response: sessions.VodSession) -> sessions.VodSession: - """Post-rpc interceptor for get_vod_session - - DEPRECATED. Please use the `post_get_vod_session_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_vod_session` interceptor runs - before the `post_get_vod_session_with_metadata` interceptor. - """ - return response - - def post_get_vod_session_with_metadata(self, response: sessions.VodSession, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[sessions.VodSession, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_vod_session - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_vod_session_with_metadata` - interceptor in new development instead of the `post_get_vod_session` interceptor. - When both interceptors are used, this `post_get_vod_session_with_metadata` interceptor runs after the - `post_get_vod_session` interceptor. The (possibly modified) response returned by - `post_get_vod_session` will be passed to - `post_get_vod_session_with_metadata`. - """ - return response, metadata - - def pre_get_vod_stitch_detail(self, request: video_stitcher_service.GetVodStitchDetailRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.GetVodStitchDetailRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_vod_stitch_detail - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_get_vod_stitch_detail(self, response: stitch_details.VodStitchDetail) -> stitch_details.VodStitchDetail: - """Post-rpc interceptor for get_vod_stitch_detail - - DEPRECATED. Please use the `post_get_vod_stitch_detail_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_get_vod_stitch_detail` interceptor runs - before the `post_get_vod_stitch_detail_with_metadata` interceptor. - """ - return response - - def post_get_vod_stitch_detail_with_metadata(self, response: stitch_details.VodStitchDetail, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[stitch_details.VodStitchDetail, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for get_vod_stitch_detail - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_get_vod_stitch_detail_with_metadata` - interceptor in new development instead of the `post_get_vod_stitch_detail` interceptor. - When both interceptors are used, this `post_get_vod_stitch_detail_with_metadata` interceptor runs after the - `post_get_vod_stitch_detail` interceptor. The (possibly modified) response returned by - `post_get_vod_stitch_detail` will be passed to - `post_get_vod_stitch_detail_with_metadata`. - """ - return response, metadata - - def pre_list_cdn_keys(self, request: video_stitcher_service.ListCdnKeysRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListCdnKeysRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_cdn_keys - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_list_cdn_keys(self, response: video_stitcher_service.ListCdnKeysResponse) -> video_stitcher_service.ListCdnKeysResponse: - """Post-rpc interceptor for list_cdn_keys - - DEPRECATED. Please use the `post_list_cdn_keys_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_list_cdn_keys` interceptor runs - before the `post_list_cdn_keys_with_metadata` interceptor. - """ - return response - - def post_list_cdn_keys_with_metadata(self, response: video_stitcher_service.ListCdnKeysResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListCdnKeysResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_cdn_keys - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_list_cdn_keys_with_metadata` - interceptor in new development instead of the `post_list_cdn_keys` interceptor. - When both interceptors are used, this `post_list_cdn_keys_with_metadata` interceptor runs after the - `post_list_cdn_keys` interceptor. The (possibly modified) response returned by - `post_list_cdn_keys` will be passed to - `post_list_cdn_keys_with_metadata`. - """ - return response, metadata - - def pre_list_live_ad_tag_details(self, request: video_stitcher_service.ListLiveAdTagDetailsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveAdTagDetailsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_live_ad_tag_details - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_list_live_ad_tag_details(self, response: video_stitcher_service.ListLiveAdTagDetailsResponse) -> video_stitcher_service.ListLiveAdTagDetailsResponse: - """Post-rpc interceptor for list_live_ad_tag_details - - DEPRECATED. Please use the `post_list_live_ad_tag_details_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_list_live_ad_tag_details` interceptor runs - before the `post_list_live_ad_tag_details_with_metadata` interceptor. - """ - return response - - def post_list_live_ad_tag_details_with_metadata(self, response: video_stitcher_service.ListLiveAdTagDetailsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveAdTagDetailsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_live_ad_tag_details - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_list_live_ad_tag_details_with_metadata` - interceptor in new development instead of the `post_list_live_ad_tag_details` interceptor. - When both interceptors are used, this `post_list_live_ad_tag_details_with_metadata` interceptor runs after the - `post_list_live_ad_tag_details` interceptor. The (possibly modified) response returned by - `post_list_live_ad_tag_details` will be passed to - `post_list_live_ad_tag_details_with_metadata`. - """ - return response, metadata - - def pre_list_live_configs(self, request: video_stitcher_service.ListLiveConfigsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_live_configs - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_list_live_configs(self, response: video_stitcher_service.ListLiveConfigsResponse) -> video_stitcher_service.ListLiveConfigsResponse: - """Post-rpc interceptor for list_live_configs - - DEPRECATED. Please use the `post_list_live_configs_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_list_live_configs` interceptor runs - before the `post_list_live_configs_with_metadata` interceptor. - """ - return response - - def post_list_live_configs_with_metadata(self, response: video_stitcher_service.ListLiveConfigsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListLiveConfigsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_live_configs - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_list_live_configs_with_metadata` - interceptor in new development instead of the `post_list_live_configs` interceptor. - When both interceptors are used, this `post_list_live_configs_with_metadata` interceptor runs after the - `post_list_live_configs` interceptor. The (possibly modified) response returned by - `post_list_live_configs` will be passed to - `post_list_live_configs_with_metadata`. - """ - return response, metadata - - def pre_list_slates(self, request: video_stitcher_service.ListSlatesRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListSlatesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_slates - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_list_slates(self, response: video_stitcher_service.ListSlatesResponse) -> video_stitcher_service.ListSlatesResponse: - """Post-rpc interceptor for list_slates - - DEPRECATED. Please use the `post_list_slates_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_list_slates` interceptor runs - before the `post_list_slates_with_metadata` interceptor. - """ - return response - - def post_list_slates_with_metadata(self, response: video_stitcher_service.ListSlatesResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListSlatesResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_slates - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_list_slates_with_metadata` - interceptor in new development instead of the `post_list_slates` interceptor. - When both interceptors are used, this `post_list_slates_with_metadata` interceptor runs after the - `post_list_slates` interceptor. The (possibly modified) response returned by - `post_list_slates` will be passed to - `post_list_slates_with_metadata`. - """ - return response, metadata - - def pre_list_vod_ad_tag_details(self, request: video_stitcher_service.ListVodAdTagDetailsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodAdTagDetailsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_vod_ad_tag_details - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_list_vod_ad_tag_details(self, response: video_stitcher_service.ListVodAdTagDetailsResponse) -> video_stitcher_service.ListVodAdTagDetailsResponse: - """Post-rpc interceptor for list_vod_ad_tag_details - - DEPRECATED. Please use the `post_list_vod_ad_tag_details_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_list_vod_ad_tag_details` interceptor runs - before the `post_list_vod_ad_tag_details_with_metadata` interceptor. - """ - return response - - def post_list_vod_ad_tag_details_with_metadata(self, response: video_stitcher_service.ListVodAdTagDetailsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodAdTagDetailsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_vod_ad_tag_details - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_list_vod_ad_tag_details_with_metadata` - interceptor in new development instead of the `post_list_vod_ad_tag_details` interceptor. - When both interceptors are used, this `post_list_vod_ad_tag_details_with_metadata` interceptor runs after the - `post_list_vod_ad_tag_details` interceptor. The (possibly modified) response returned by - `post_list_vod_ad_tag_details` will be passed to - `post_list_vod_ad_tag_details_with_metadata`. - """ - return response, metadata - - def pre_list_vod_configs(self, request: video_stitcher_service.ListVodConfigsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_vod_configs - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_list_vod_configs(self, response: video_stitcher_service.ListVodConfigsResponse) -> video_stitcher_service.ListVodConfigsResponse: - """Post-rpc interceptor for list_vod_configs - - DEPRECATED. Please use the `post_list_vod_configs_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_list_vod_configs` interceptor runs - before the `post_list_vod_configs_with_metadata` interceptor. - """ - return response - - def post_list_vod_configs_with_metadata(self, response: video_stitcher_service.ListVodConfigsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodConfigsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_vod_configs - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_list_vod_configs_with_metadata` - interceptor in new development instead of the `post_list_vod_configs` interceptor. - When both interceptors are used, this `post_list_vod_configs_with_metadata` interceptor runs after the - `post_list_vod_configs` interceptor. The (possibly modified) response returned by - `post_list_vod_configs` will be passed to - `post_list_vod_configs_with_metadata`. - """ - return response, metadata - - def pre_list_vod_stitch_details(self, request: video_stitcher_service.ListVodStitchDetailsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodStitchDetailsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_vod_stitch_details - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_list_vod_stitch_details(self, response: video_stitcher_service.ListVodStitchDetailsResponse) -> video_stitcher_service.ListVodStitchDetailsResponse: - """Post-rpc interceptor for list_vod_stitch_details - - DEPRECATED. Please use the `post_list_vod_stitch_details_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_list_vod_stitch_details` interceptor runs - before the `post_list_vod_stitch_details_with_metadata` interceptor. - """ - return response - - def post_list_vod_stitch_details_with_metadata(self, response: video_stitcher_service.ListVodStitchDetailsResponse, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.ListVodStitchDetailsResponse, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for list_vod_stitch_details - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_list_vod_stitch_details_with_metadata` - interceptor in new development instead of the `post_list_vod_stitch_details` interceptor. - When both interceptors are used, this `post_list_vod_stitch_details_with_metadata` interceptor runs after the - `post_list_vod_stitch_details` interceptor. The (possibly modified) response returned by - `post_list_vod_stitch_details` will be passed to - `post_list_vod_stitch_details_with_metadata`. - """ - return response, metadata - - def pre_update_cdn_key(self, request: video_stitcher_service.UpdateCdnKeyRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_cdn_key - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_update_cdn_key(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_cdn_key - - DEPRECATED. Please use the `post_update_cdn_key_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_update_cdn_key` interceptor runs - before the `post_update_cdn_key_with_metadata` interceptor. - """ - return response - - def post_update_cdn_key_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_cdn_key - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_update_cdn_key_with_metadata` - interceptor in new development instead of the `post_update_cdn_key` interceptor. - When both interceptors are used, this `post_update_cdn_key_with_metadata` interceptor runs after the - `post_update_cdn_key` interceptor. The (possibly modified) response returned by - `post_update_cdn_key` will be passed to - `post_update_cdn_key_with_metadata`. - """ - return response, metadata - - def pre_update_live_config(self, request: video_stitcher_service.UpdateLiveConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateLiveConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_live_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_update_live_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_live_config - - DEPRECATED. Please use the `post_update_live_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_update_live_config` interceptor runs - before the `post_update_live_config_with_metadata` interceptor. - """ - return response - - def post_update_live_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_live_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_update_live_config_with_metadata` - interceptor in new development instead of the `post_update_live_config` interceptor. - When both interceptors are used, this `post_update_live_config_with_metadata` interceptor runs after the - `post_update_live_config` interceptor. The (possibly modified) response returned by - `post_update_live_config` will be passed to - `post_update_live_config_with_metadata`. - """ - return response, metadata - - def pre_update_slate(self, request: video_stitcher_service.UpdateSlateRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateSlateRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_slate - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_update_slate(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_slate - - DEPRECATED. Please use the `post_update_slate_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_update_slate` interceptor runs - before the `post_update_slate_with_metadata` interceptor. - """ - return response - - def post_update_slate_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_slate - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_update_slate_with_metadata` - interceptor in new development instead of the `post_update_slate` interceptor. - When both interceptors are used, this `post_update_slate_with_metadata` interceptor runs after the - `post_update_slate` interceptor. The (possibly modified) response returned by - `post_update_slate` will be passed to - `post_update_slate_with_metadata`. - """ - return response, metadata - - def pre_update_vod_config(self, request: video_stitcher_service.UpdateVodConfigRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[video_stitcher_service.UpdateVodConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for update_vod_config - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_update_vod_config(self, response: operations_pb2.Operation) -> operations_pb2.Operation: - """Post-rpc interceptor for update_vod_config - - DEPRECATED. Please use the `post_update_vod_config_with_metadata` - interceptor instead. - - Override in a subclass to read or manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. This `post_update_vod_config` interceptor runs - before the `post_update_vod_config_with_metadata` interceptor. - """ - return response - - def post_update_vod_config_with_metadata(self, response: operations_pb2.Operation, metadata: Sequence[Tuple[str, Union[str, bytes]]]) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: - """Post-rpc interceptor for update_vod_config - - Override in a subclass to read or manipulate the response or metadata after it - is returned by the VideoStitcherService server but before it is returned to user code. - - We recommend only using this `post_update_vod_config_with_metadata` - interceptor in new development instead of the `post_update_vod_config` interceptor. - When both interceptors are used, this `post_update_vod_config_with_metadata` interceptor runs after the - `post_update_vod_config` interceptor. The (possibly modified) response returned by - `post_update_vod_config` will be passed to - `post_update_vod_config_with_metadata`. - """ - return response, metadata - - def pre_cancel_operation( - self, request: operations_pb2.CancelOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for cancel_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService 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 VideoStitcherService server but before - it is returned to user code. - """ - return response - - def pre_delete_operation( - self, request: operations_pb2.DeleteOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for delete_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. - """ - return request, metadata - - def post_delete_operation( - self, response: None - ) -> None: - """Post-rpc interceptor for delete_operation - - Override in a subclass to manipulate the response - after it is returned by the VideoStitcherService server but before - it is returned to user code. - """ - return response - - def pre_get_operation( - self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for get_operation - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService 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 VideoStitcherService server but before - it is returned to user code. - """ - return response - - def pre_list_operations( - self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, Union[str, bytes]]] - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: - """Pre-rpc interceptor for list_operations - - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService 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 VideoStitcherService server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class VideoStitcherServiceRestStub: - _session: AuthorizedSession - _host: str - _interceptor: VideoStitcherServiceRestInterceptor - - -class VideoStitcherServiceRestTransport(_BaseVideoStitcherServiceRestTransport): - """REST backend synchronous transport for VideoStitcherService. - - Video-On-Demand content stitching API allows you to insert - ads into (VoD) video on demand files. You will be able to render - custom scrubber bars with highlighted ads, enforce ad policies, - allow seamless playback and tracking on native players and - monetize content with any standard VMAP compliant ad server. - - 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 = 'videostitcher.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[VideoStitcherServiceRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to (default: 'videostitcher.googleapis.com'). - 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 - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - url_scheme=url_scheme, - 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 VideoStitcherServiceRestInterceptor() - self._prep_wrapped_messages(client_info) - - @property - def operations_client(self) -> operations_v1.AbstractOperationsClient: - """Create the client designed to process long-running operations. - - This property caches on the instance; repeated calls return the same - client. - """ - # Only create a new client if we do not already have one. - if self._operations_client is None: - http_options: Dict[str, List[Dict[str, str]]] = { - 'google.longrunning.Operations.CancelOperation': [ - { - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', - 'body': '*', - }, - ], - 'google.longrunning.Operations.DeleteOperation': [ - { - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.GetOperation': [ - { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, - ], - 'google.longrunning.Operations.ListOperations': [ - { - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}/operations', - }, - ], - } - - rest_transport = operations_v1.OperationsRestTransport( - host=self._host, - # use the credentials which are saved - credentials=self._credentials, - scopes=self._scopes, - http_options=http_options, - path_prefix="v1") - - self._operations_client = operations_v1.AbstractOperationsClient(transport=rest_transport) - - # Return the client from cache. - return self._operations_client - - class _CreateCdnKey(_BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.CreateCdnKey") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.CreateCdnKeyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create cdn key method over HTTP. - - Args: - request (~.video_stitcher_service.CreateCdnKeyRequest): - The request object. Request message for - VideoStitcherService.createCdnKey. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_http_options() - - request, metadata = self._interceptor.pre_create_cdn_key(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateCdnKey", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateCdnKey", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._CreateCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_cdn_key(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_cdn_key_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_cdn_key", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateCdnKey", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.CreateLiveConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.CreateLiveConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create live config method over HTTP. - - Args: - request (~.video_stitcher_service.CreateLiveConfigRequest): - The request object. Request message for - VideoStitcherService.createLiveConfig - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_http_options() - - request, metadata = self._interceptor.pre_create_live_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateLiveConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateLiveConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._CreateLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_live_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_live_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateLiveConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateLiveSession(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.CreateLiveSession") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.CreateLiveSessionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> sessions.LiveSession: - r"""Call the create live session method over HTTP. - - Args: - request (~.video_stitcher_service.CreateLiveSessionRequest): - The request object. Request message for - VideoStitcherService.createLiveSession. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.sessions.LiveSession: - Metadata for a live session. The - session expires 5 minutes after the - client stops fetching the session's - playlists. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_http_options() - - request, metadata = self._interceptor.pre_create_live_session(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateLiveSession", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateLiveSession", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._CreateLiveSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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 = sessions.LiveSession() - pb_resp = sessions.LiveSession.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_create_live_session(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_live_session_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = sessions.LiveSession.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_session", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateLiveSession", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateSlate(_BaseVideoStitcherServiceRestTransport._BaseCreateSlate, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.CreateSlate") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.CreateSlateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create slate method over HTTP. - - Args: - request (~.video_stitcher_service.CreateSlateRequest): - The request object. Request message for - VideoStitcherService.createSlate. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_http_options() - - request, metadata = self._interceptor.pre_create_slate(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateSlate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateSlate", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._CreateSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_slate(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_slate_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_slate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateSlate", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateVodConfig(_BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.CreateVodConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.CreateVodConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the create vod config method over HTTP. - - Args: - request (~.video_stitcher_service.CreateVodConfigRequest): - The request object. Request message for - VideoStitcherService.createVodConfig - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_http_options() - - request, metadata = self._interceptor.pre_create_vod_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateVodConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateVodConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._CreateVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_vod_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_vod_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateVodConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _CreateVodSession(_BaseVideoStitcherServiceRestTransport._BaseCreateVodSession, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.CreateVodSession") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.CreateVodSessionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> sessions.VodSession: - r"""Call the create vod session method over HTTP. - - Args: - request (~.video_stitcher_service.CreateVodSessionRequest): - The request object. Request message for - VideoStitcherService.createVodSession - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.sessions.VodSession: - Metadata for a VOD session. The - session expires 4 hours after its - creation. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_http_options() - - request, metadata = self._interceptor.pre_create_vod_session(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateVodSession", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateVodSession", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._CreateVodSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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 = sessions.VodSession() - pb_resp = sessions.VodSession.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_create_vod_session(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_create_vod_session_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = sessions.VodSession.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_session", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CreateVodSession", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteCdnKey(_BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.DeleteCdnKey") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.DeleteCdnKeyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete cdn key method over HTTP. - - Args: - request (~.video_stitcher_service.DeleteCdnKeyRequest): - The request object. Request message for - VideoStitcherService.deleteCdnKey. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_http_options() - - request, metadata = self._interceptor.pre_delete_cdn_key(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteCdnKey", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteCdnKey", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._DeleteCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_delete_cdn_key(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_cdn_key_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_cdn_key", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteCdnKey", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.DeleteLiveConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.DeleteLiveConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete live config method over HTTP. - - Args: - request (~.video_stitcher_service.DeleteLiveConfigRequest): - The request object. Request message for - VideoStitcherService.deleteLiveConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_http_options() - - request, metadata = self._interceptor.pre_delete_live_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteLiveConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteLiveConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._DeleteLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_delete_live_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_live_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_live_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteLiveConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteSlate(_BaseVideoStitcherServiceRestTransport._BaseDeleteSlate, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.DeleteSlate") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.DeleteSlateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete slate method over HTTP. - - Args: - request (~.video_stitcher_service.DeleteSlateRequest): - The request object. Request message for - VideoStitcherService.deleteSlate. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_http_options() - - request, metadata = self._interceptor.pre_delete_slate(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteSlate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteSlate", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._DeleteSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_delete_slate(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_slate_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_slate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteSlate", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _DeleteVodConfig(_BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.DeleteVodConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.DeleteVodConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the delete vod config method over HTTP. - - Args: - request (~.video_stitcher_service.DeleteVodConfigRequest): - The request object. Request message for - VideoStitcherService.deleteVodConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_http_options() - - request, metadata = self._interceptor.pre_delete_vod_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteVodConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteVodConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._DeleteVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = operations_pb2.Operation() - json_format.Parse(response.content, resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_delete_vod_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_delete_vod_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_vod_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteVodConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetCdnKey(_BaseVideoStitcherServiceRestTransport._BaseGetCdnKey, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetCdnKey") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetCdnKeyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> cdn_keys.CdnKey: - r"""Call the get cdn key method over HTTP. - - Args: - request (~.video_stitcher_service.GetCdnKeyRequest): - The request object. Request message for - VideoStitcherService.getCdnKey. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.cdn_keys.CdnKey: - Configuration for a CDN key. Used by - the Video Stitcher to sign URIs for - fetching video manifests and signing - media segments for playback. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_http_options() - - request, metadata = self._interceptor.pre_get_cdn_key(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetCdnKey", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetCdnKey", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = cdn_keys.CdnKey() - pb_resp = cdn_keys.CdnKey.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_cdn_key(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_cdn_key_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = cdn_keys.CdnKey.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_cdn_key", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetCdnKey", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetLiveAdTagDetail(_BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetLiveAdTagDetail") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetLiveAdTagDetailRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> ad_tag_details.LiveAdTagDetail: - r"""Call the get live ad tag detail method over HTTP. - - Args: - request (~.video_stitcher_service.GetLiveAdTagDetailRequest): - The request object. Request message for - VideoStitcherService.getLiveAdTagDetail - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.ad_tag_details.LiveAdTagDetail: - Information related to the details - for one ad tag. This resource is only - available for live sessions that do not - implement Google Ad Manager ad - insertion. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_http_options() - - request, metadata = self._interceptor.pre_get_live_ad_tag_detail(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveAdTagDetail", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetLiveAdTagDetail", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetLiveAdTagDetail._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = ad_tag_details.LiveAdTagDetail() - pb_resp = ad_tag_details.LiveAdTagDetail.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_live_ad_tag_detail(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_live_ad_tag_detail_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = ad_tag_details.LiveAdTagDetail.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_ad_tag_detail", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetLiveAdTagDetail", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetLiveConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetLiveConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> live_configs.LiveConfig: - r"""Call the get live config method over HTTP. - - Args: - request (~.video_stitcher_service.GetLiveConfigRequest): - The request object. Request message for - VideoStitcherService.getLiveConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.live_configs.LiveConfig: - Metadata for used to register live - configs. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_http_options() - - request, metadata = self._interceptor.pre_get_live_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetLiveConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = live_configs.LiveConfig() - pb_resp = live_configs.LiveConfig.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_live_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_live_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = live_configs.LiveConfig.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetLiveConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetLiveSession(_BaseVideoStitcherServiceRestTransport._BaseGetLiveSession, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetLiveSession") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetLiveSessionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> sessions.LiveSession: - r"""Call the get live session method over HTTP. - - Args: - request (~.video_stitcher_service.GetLiveSessionRequest): - The request object. Request message for - VideoStitcherService.getSession. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.sessions.LiveSession: - Metadata for a live session. The - session expires 5 minutes after the - client stops fetching the session's - playlists. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_http_options() - - request, metadata = self._interceptor.pre_get_live_session(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveSession", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetLiveSession", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetLiveSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = sessions.LiveSession() - pb_resp = sessions.LiveSession.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_live_session(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_live_session_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = sessions.LiveSession.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_session", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetLiveSession", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetSlate(_BaseVideoStitcherServiceRestTransport._BaseGetSlate, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetSlate") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetSlateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> slates.Slate: - r"""Call the get slate method over HTTP. - - Args: - request (~.video_stitcher_service.GetSlateRequest): - The request object. Request message for - VideoStitcherService.getSlate. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.slates.Slate: - Slate object - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_http_options() - - request, metadata = self._interceptor.pre_get_slate(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetSlate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetSlate", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = slates.Slate() - pb_resp = slates.Slate.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_slate(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_slate_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = slates.Slate.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_slate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetSlate", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetVodAdTagDetail(_BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetVodAdTagDetail") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetVodAdTagDetailRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> ad_tag_details.VodAdTagDetail: - r"""Call the get vod ad tag detail method over HTTP. - - Args: - request (~.video_stitcher_service.GetVodAdTagDetailRequest): - The request object. Request message for - VideoStitcherService.getVodAdTagDetail - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.ad_tag_details.VodAdTagDetail: - Information related to the details - for one ad tag. This resource is only - available for VOD sessions that do not - implement Google Ad Manager ad - insertion. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_http_options() - - request, metadata = self._interceptor.pre_get_vod_ad_tag_detail(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodAdTagDetail", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodAdTagDetail", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetVodAdTagDetail._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = ad_tag_details.VodAdTagDetail() - pb_resp = ad_tag_details.VodAdTagDetail.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_vod_ad_tag_detail(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_vod_ad_tag_detail_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = ad_tag_details.VodAdTagDetail.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_ad_tag_detail", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodAdTagDetail", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetVodConfig(_BaseVideoStitcherServiceRestTransport._BaseGetVodConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetVodConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetVodConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> vod_configs.VodConfig: - r"""Call the get vod config method over HTTP. - - Args: - request (~.video_stitcher_service.GetVodConfigRequest): - The request object. Request message for - VideoStitcherService.getVodConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.vod_configs.VodConfig: - Metadata used to register VOD - configs. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_http_options() - - request, metadata = self._interceptor.pre_get_vod_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = vod_configs.VodConfig() - pb_resp = vod_configs.VodConfig.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_vod_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_vod_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = vod_configs.VodConfig.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetVodSession(_BaseVideoStitcherServiceRestTransport._BaseGetVodSession, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetVodSession") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetVodSessionRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> sessions.VodSession: - r"""Call the get vod session method over HTTP. - - Args: - request (~.video_stitcher_service.GetVodSessionRequest): - The request object. Request message for - VideoStitcherService.getVodSession - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.sessions.VodSession: - Metadata for a VOD session. The - session expires 4 hours after its - creation. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_http_options() - - request, metadata = self._interceptor.pre_get_vod_session(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodSession", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodSession", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetVodSession._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = sessions.VodSession() - pb_resp = sessions.VodSession.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_vod_session(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_vod_session_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = sessions.VodSession.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_session", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodSession", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _GetVodStitchDetail(_BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetVodStitchDetail") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.GetVodStitchDetailRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> stitch_details.VodStitchDetail: - r"""Call the get vod stitch detail method over HTTP. - - Args: - request (~.video_stitcher_service.GetVodStitchDetailRequest): - The request object. Request message for - VideoStitcherService.getVodStitchDetail. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.stitch_details.VodStitchDetail: - Information related to the - interstitial of a VOD session. This - resource is only available for VOD - sessions that do not implement Google Ad - Manager ad insertion. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_http_options() - - request, metadata = self._interceptor.pre_get_vod_stitch_detail(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodStitchDetail", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodStitchDetail", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetVodStitchDetail._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = stitch_details.VodStitchDetail() - pb_resp = stitch_details.VodStitchDetail.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_get_vod_stitch_detail(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_get_vod_stitch_detail_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = stitch_details.VodStitchDetail.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_stitch_detail", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetVodStitchDetail", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListCdnKeys(_BaseVideoStitcherServiceRestTransport._BaseListCdnKeys, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListCdnKeys") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.ListCdnKeysRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> video_stitcher_service.ListCdnKeysResponse: - r"""Call the list cdn keys method over HTTP. - - Args: - request (~.video_stitcher_service.ListCdnKeysRequest): - The request object. Request message for - VideoStitcherService.listCdnKeys. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.video_stitcher_service.ListCdnKeysResponse: - Response message for - VideoStitcher.ListCdnKeys. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_http_options() - - request, metadata = self._interceptor.pre_list_cdn_keys(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListCdnKeys", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListCdnKeys", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListCdnKeys._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = video_stitcher_service.ListCdnKeysResponse() - pb_resp = video_stitcher_service.ListCdnKeysResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_cdn_keys(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_cdn_keys_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = video_stitcher_service.ListCdnKeysResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_cdn_keys", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListCdnKeys", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListLiveAdTagDetails(_BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListLiveAdTagDetails") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.ListLiveAdTagDetailsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> video_stitcher_service.ListLiveAdTagDetailsResponse: - r"""Call the list live ad tag details method over HTTP. - - Args: - request (~.video_stitcher_service.ListLiveAdTagDetailsRequest): - The request object. Request message for - VideoStitcherService.listLiveAdTagDetails. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.video_stitcher_service.ListLiveAdTagDetailsResponse: - Response message for - VideoStitcherService.listLiveAdTagDetails. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_http_options() - - request, metadata = self._interceptor.pre_list_live_ad_tag_details(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListLiveAdTagDetails", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListLiveAdTagDetails", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListLiveAdTagDetails._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = video_stitcher_service.ListLiveAdTagDetailsResponse() - pb_resp = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_live_ad_tag_details(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_live_ad_tag_details_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = video_stitcher_service.ListLiveAdTagDetailsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_ad_tag_details", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListLiveAdTagDetails", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListLiveConfigs(_BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListLiveConfigs") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.ListLiveConfigsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> video_stitcher_service.ListLiveConfigsResponse: - r"""Call the list live configs method over HTTP. - - Args: - request (~.video_stitcher_service.ListLiveConfigsRequest): - The request object. Request message for - VideoStitcherService.listLiveConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.video_stitcher_service.ListLiveConfigsResponse: - Response message for - VideoStitcher.ListLiveConfig. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_http_options() - - request, metadata = self._interceptor.pre_list_live_configs(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListLiveConfigs", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListLiveConfigs", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListLiveConfigs._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = video_stitcher_service.ListLiveConfigsResponse() - pb_resp = video_stitcher_service.ListLiveConfigsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_live_configs(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_live_configs_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = video_stitcher_service.ListLiveConfigsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_configs", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListLiveConfigs", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListSlates(_BaseVideoStitcherServiceRestTransport._BaseListSlates, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListSlates") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.ListSlatesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> video_stitcher_service.ListSlatesResponse: - r"""Call the list slates method over HTTP. - - Args: - request (~.video_stitcher_service.ListSlatesRequest): - The request object. Request message for - VideoStitcherService.listSlates. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.video_stitcher_service.ListSlatesResponse: - Response message for - VideoStitcherService.listSlates. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_http_options() - - request, metadata = self._interceptor.pre_list_slates(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListSlates", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListSlates", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListSlates._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = video_stitcher_service.ListSlatesResponse() - pb_resp = video_stitcher_service.ListSlatesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_slates(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_slates_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = video_stitcher_service.ListSlatesResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_slates", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListSlates", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListVodAdTagDetails(_BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListVodAdTagDetails") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.ListVodAdTagDetailsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> video_stitcher_service.ListVodAdTagDetailsResponse: - r"""Call the list vod ad tag details method over HTTP. - - Args: - request (~.video_stitcher_service.ListVodAdTagDetailsRequest): - The request object. Request message for - VideoStitcherService.listVodAdTagDetails. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.video_stitcher_service.ListVodAdTagDetailsResponse: - Response message for - VideoStitcherService.listVodAdTagDetails. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_http_options() - - request, metadata = self._interceptor.pre_list_vod_ad_tag_details(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodAdTagDetails", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListVodAdTagDetails", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListVodAdTagDetails._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = video_stitcher_service.ListVodAdTagDetailsResponse() - pb_resp = video_stitcher_service.ListVodAdTagDetailsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_vod_ad_tag_details(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_vod_ad_tag_details_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = video_stitcher_service.ListVodAdTagDetailsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_ad_tag_details", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListVodAdTagDetails", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListVodConfigs(_BaseVideoStitcherServiceRestTransport._BaseListVodConfigs, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListVodConfigs") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.ListVodConfigsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> video_stitcher_service.ListVodConfigsResponse: - r"""Call the list vod configs method over HTTP. - - Args: - request (~.video_stitcher_service.ListVodConfigsRequest): - The request object. Request message for - VideoStitcherService.listVodConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.video_stitcher_service.ListVodConfigsResponse: - Response message for - VideoStitcher.ListVodConfig. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_http_options() - - request, metadata = self._interceptor.pre_list_vod_configs(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodConfigs", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListVodConfigs", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListVodConfigs._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = video_stitcher_service.ListVodConfigsResponse() - pb_resp = video_stitcher_service.ListVodConfigsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_vod_configs(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_vod_configs_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = video_stitcher_service.ListVodConfigsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_configs", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListVodConfigs", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _ListVodStitchDetails(_BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListVodStitchDetails") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: video_stitcher_service.ListVodStitchDetailsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> video_stitcher_service.ListVodStitchDetailsResponse: - r"""Call the list vod stitch details method over HTTP. - - Args: - request (~.video_stitcher_service.ListVodStitchDetailsRequest): - The request object. Request message for - VideoStitcherService.listVodStitchDetails. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.video_stitcher_service.ListVodStitchDetailsResponse: - Response message for - VideoStitcherService.listVodStitchDetails. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_http_options() - - request, metadata = self._interceptor.pre_list_vod_stitch_details(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = type(request).to_json(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodStitchDetails", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListVodStitchDetails", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListVodStitchDetails._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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 = video_stitcher_service.ListVodStitchDetailsResponse() - pb_resp = video_stitcher_service.ListVodStitchDetailsResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - - resp = self._interceptor.post_list_vod_stitch_details(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_list_vod_stitch_details_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = video_stitcher_service.ListVodStitchDetailsResponse.to_json(response) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_stitch_details", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListVodStitchDetails", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateCdnKey(_BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.UpdateCdnKey") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.UpdateCdnKeyRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update cdn key method over HTTP. - - Args: - request (~.video_stitcher_service.UpdateCdnKeyRequest): - The request object. Request message for - VideoStitcherService.updateCdnKey. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_http_options() - - request, metadata = self._interceptor.pre_update_cdn_key(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateCdnKey", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateCdnKey", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._UpdateCdnKey._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_cdn_key(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_cdn_key_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_cdn_key", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateCdnKey", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateLiveConfig(_BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.UpdateLiveConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.UpdateLiveConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update live config method over HTTP. - - Args: - request (~.video_stitcher_service.UpdateLiveConfigRequest): - The request object. Request message for - VideoStitcherService.updateLiveConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_http_options() - - request, metadata = self._interceptor.pre_update_live_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateLiveConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateLiveConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._UpdateLiveConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_live_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_live_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_live_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateLiveConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateSlate(_BaseVideoStitcherServiceRestTransport._BaseUpdateSlate, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.UpdateSlate") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.UpdateSlateRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update slate method over HTTP. - - Args: - request (~.video_stitcher_service.UpdateSlateRequest): - The request object. Request message for - VideoStitcherService.updateSlate. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_http_options() - - request, metadata = self._interceptor.pre_update_slate(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateSlate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateSlate", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._UpdateSlate._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_slate(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_slate_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_slate", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateSlate", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - class _UpdateVodConfig(_BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.UpdateVodConfig") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: video_stitcher_service.UpdateVodConfigRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> operations_pb2.Operation: - r"""Call the update vod config method over HTTP. - - Args: - request (~.video_stitcher_service.UpdateVodConfigRequest): - The request object. Request message for - VideoStitcherService.updateVodConfig. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - ~.operations_pb2.Operation: - This resource represents a - long-running operation that is the - result of a network API call. - - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_http_options() - - request, metadata = self._interceptor.pre_update_vod_config(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateVodConfig", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateVodConfig", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._UpdateVodConfig._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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_vod_config(resp) - response_metadata = [(k, str(v)) for k, v in response.headers.items()] - resp, _ = self._interceptor.post_update_vod_config_with_metadata(resp, response_metadata) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_vod_config", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "UpdateVodConfig", - "metadata": http_response["headers"], - "httpResponse": http_response, - }, - ) - return resp - - @property - def create_cdn_key(self) -> Callable[ - [video_stitcher_service.CreateCdnKeyRequest], - 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._CreateCdnKey(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_live_config(self) -> Callable[ - [video_stitcher_service.CreateLiveConfigRequest], - 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._CreateLiveConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_live_session(self) -> Callable[ - [video_stitcher_service.CreateLiveSessionRequest], - sessions.LiveSession]: - # 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._CreateLiveSession(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_slate(self) -> Callable[ - [video_stitcher_service.CreateSlateRequest], - 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._CreateSlate(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_vod_config(self) -> Callable[ - [video_stitcher_service.CreateVodConfigRequest], - 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._CreateVodConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_vod_session(self) -> Callable[ - [video_stitcher_service.CreateVodSessionRequest], - sessions.VodSession]: - # 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._CreateVodSession(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_cdn_key(self) -> Callable[ - [video_stitcher_service.DeleteCdnKeyRequest], - 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._DeleteCdnKey(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_live_config(self) -> Callable[ - [video_stitcher_service.DeleteLiveConfigRequest], - 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._DeleteLiveConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_slate(self) -> Callable[ - [video_stitcher_service.DeleteSlateRequest], - 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._DeleteSlate(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_vod_config(self) -> Callable[ - [video_stitcher_service.DeleteVodConfigRequest], - 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._DeleteVodConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_cdn_key(self) -> Callable[ - [video_stitcher_service.GetCdnKeyRequest], - cdn_keys.CdnKey]: - # 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._GetCdnKey(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_live_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetLiveAdTagDetailRequest], - ad_tag_details.LiveAdTagDetail]: - # 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._GetLiveAdTagDetail(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_live_config(self) -> Callable[ - [video_stitcher_service.GetLiveConfigRequest], - live_configs.LiveConfig]: - # 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._GetLiveConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_live_session(self) -> Callable[ - [video_stitcher_service.GetLiveSessionRequest], - sessions.LiveSession]: - # 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._GetLiveSession(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_slate(self) -> Callable[ - [video_stitcher_service.GetSlateRequest], - slates.Slate]: - # 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._GetSlate(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_vod_ad_tag_detail(self) -> Callable[ - [video_stitcher_service.GetVodAdTagDetailRequest], - ad_tag_details.VodAdTagDetail]: - # 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._GetVodAdTagDetail(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_vod_config(self) -> Callable[ - [video_stitcher_service.GetVodConfigRequest], - vod_configs.VodConfig]: - # 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._GetVodConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_vod_session(self) -> Callable[ - [video_stitcher_service.GetVodSessionRequest], - sessions.VodSession]: - # 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._GetVodSession(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_vod_stitch_detail(self) -> Callable[ - [video_stitcher_service.GetVodStitchDetailRequest], - stitch_details.VodStitchDetail]: - # 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._GetVodStitchDetail(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_cdn_keys(self) -> Callable[ - [video_stitcher_service.ListCdnKeysRequest], - video_stitcher_service.ListCdnKeysResponse]: - # 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._ListCdnKeys(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_live_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListLiveAdTagDetailsRequest], - video_stitcher_service.ListLiveAdTagDetailsResponse]: - # 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._ListLiveAdTagDetails(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_live_configs(self) -> Callable[ - [video_stitcher_service.ListLiveConfigsRequest], - video_stitcher_service.ListLiveConfigsResponse]: - # 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._ListLiveConfigs(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_slates(self) -> Callable[ - [video_stitcher_service.ListSlatesRequest], - video_stitcher_service.ListSlatesResponse]: - # 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._ListSlates(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_vod_ad_tag_details(self) -> Callable[ - [video_stitcher_service.ListVodAdTagDetailsRequest], - video_stitcher_service.ListVodAdTagDetailsResponse]: - # 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._ListVodAdTagDetails(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_vod_configs(self) -> Callable[ - [video_stitcher_service.ListVodConfigsRequest], - video_stitcher_service.ListVodConfigsResponse]: - # 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._ListVodConfigs(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_vod_stitch_details(self) -> Callable[ - [video_stitcher_service.ListVodStitchDetailsRequest], - video_stitcher_service.ListVodStitchDetailsResponse]: - # 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._ListVodStitchDetails(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_cdn_key(self) -> Callable[ - [video_stitcher_service.UpdateCdnKeyRequest], - 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._UpdateCdnKey(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_live_config(self) -> Callable[ - [video_stitcher_service.UpdateLiveConfigRequest], - 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._UpdateLiveConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_slate(self) -> Callable[ - [video_stitcher_service.UpdateSlateRequest], - 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._UpdateSlate(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_vod_config(self) -> Callable[ - [video_stitcher_service.UpdateVodConfigRequest], - 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._UpdateVodConfig(self._session, self._host, self._interceptor) # type: ignore - - @property - def cancel_operation(self): - return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore - - class _CancelOperation(_BaseVideoStitcherServiceRestTransport._BaseCancelOperation, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.CancelOperation") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - return response - - def __call__(self, - request: operations_pb2.CancelOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_http_options() - - request, metadata = self._interceptor.pre_cancel_operation(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_transcoded_request(http_options, request) - - body = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_request_body_json(transcoded_request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CancelOperation", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "CancelOperation", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._CancelOperation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request, 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 self._interceptor.post_cancel_operation(None) - - @property - def delete_operation(self): - return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore - - class _DeleteOperation(_BaseVideoStitcherServiceRestTransport._BaseDeleteOperation, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.DeleteOperation") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: operations_pb2.DeleteOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> None: - - r"""Call the delete operation method over HTTP. - - Args: - request (operations_pb2.DeleteOperationRequest): - The request object for DeleteOperation method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_http_options() - - request, metadata = self._interceptor.pre_delete_operation(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteOperation", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "DeleteOperation", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._DeleteOperation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # 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_delete_operation(None) - - @property - def get_operation(self): - return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore - - class _GetOperation(_BaseVideoStitcherServiceRestTransport._BaseGetOperation, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.GetOperation") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: operations_pb2.GetOperationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - operations_pb2.Operation: Response from GetOperation method. - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_http_options() - - request, metadata = self._interceptor.pre_get_operation(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetOperation", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetOperation", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._GetOperation._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - content = response.content.decode("utf-8") - resp = operations_pb2.Operation() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_get_operation(resp) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.GetOperation", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "GetOperation", - "httpResponse": http_response, - "metadata": http_response["headers"], - }, - ) - return resp - - @property - def list_operations(self): - return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore - - class _ListOperations(_BaseVideoStitcherServiceRestTransport._BaseListOperations, VideoStitcherServiceRestStub): - def __hash__(self): - return hash("VideoStitcherServiceRestTransport.ListOperations") - - @staticmethod - def _get_response( - host, - metadata, - query_params, - session, - timeout, - transcoded_request, - body=None): - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(session, method)( - "{host}{uri}".format(host=host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - return response - - def __call__(self, - request: operations_pb2.ListOperationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, Union[str, bytes]]]=(), - ) -> 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, Union[str, bytes]]]): Key/value pairs which should be - sent along with the request as metadata. Normally, each value must be of type `str`, - but for metadata keys ending with the suffix `-bin`, the corresponding values must - be of type `bytes`. - - Returns: - operations_pb2.ListOperationsResponse: Response from ListOperations method. - """ - - http_options = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_http_options() - - request, metadata = self._interceptor.pre_list_operations(request, metadata) - transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_transcoded_request(http_options, request) - - # Jsonify the query params - query_params = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_query_params_json(transcoded_request) - - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - request_url = "{host}{uri}".format(host=self._host, uri=transcoded_request['uri']) - method = transcoded_request['method'] - try: - request_payload = json_format.MessageToJson(request) - except: - request_payload = None - http_request = { - "payload": request_payload, - "requestMethod": method, - "requestUrl": request_url, - "headers": dict(metadata), - } - _LOGGER.debug( - f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListOperations", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListOperations", - "httpRequest": http_request, - "metadata": http_request["headers"], - }, - ) - - # Send the request - response = VideoStitcherServiceRestTransport._ListOperations._get_response(self._host, metadata, query_params, self._session, timeout, transcoded_request) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - content = response.content.decode("utf-8") - resp = operations_pb2.ListOperationsResponse() - resp = json_format.Parse(content, resp) - resp = self._interceptor.post_list_operations(resp) - if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(logging.DEBUG): # pragma: NO COVER - try: - response_payload = json_format.MessageToJson(resp) - except: - response_payload = None - http_response = { - "payload": response_payload, - "headers": dict(response.headers), - "status": response.status_code, - } - _LOGGER.debug( - "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.ListOperations", - extra = { - "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "rpcName": "ListOperations", - "httpResponse": http_response, - "metadata": http_response["headers"], - }, - ) - return resp - - @property - def kind(self) -> str: - return "rest" - - def close(self): - self._session.close() - - -__all__=( - 'VideoStitcherServiceRestTransport', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py deleted file mode 100644 index 5e827f8ab244..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/__init__.py +++ /dev/null @@ -1,184 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 .ad_tag_details import ( - AdRequest, - LiveAdTagDetail, - RequestMetadata, - ResponseMetadata, - VodAdTagDetail, -) -from .cdn_keys import ( - AkamaiCdnKey, - CdnKey, - GoogleCdnKey, - MediaCdnKey, -) -from .companions import ( - Companion, - CompanionAds, - HtmlAdResource, - IframeAdResource, - StaticAdResource, -) -from .events import ( - Event, - ProgressEvent, -) -from .fetch_options import ( - FetchOptions, -) -from .live_configs import ( - GamLiveConfig, - LiveConfig, - PrefetchConfig, - AdTracking, -) -from .sessions import ( - Interstitials, - LiveSession, - ManifestOptions, - RenditionFilter, - VodSession, - VodSessionAd, - VodSessionAdBreak, - VodSessionContent, -) -from .slates import ( - Slate, -) -from .stitch_details import ( - AdStitchDetail, - VodStitchDetail, -) -from .video_stitcher_service import ( - CreateCdnKeyRequest, - CreateLiveConfigRequest, - CreateLiveSessionRequest, - CreateSlateRequest, - CreateVodConfigRequest, - CreateVodSessionRequest, - DeleteCdnKeyRequest, - DeleteLiveConfigRequest, - DeleteSlateRequest, - DeleteVodConfigRequest, - GetCdnKeyRequest, - GetLiveAdTagDetailRequest, - GetLiveConfigRequest, - GetLiveSessionRequest, - GetSlateRequest, - GetVodAdTagDetailRequest, - GetVodConfigRequest, - GetVodSessionRequest, - GetVodStitchDetailRequest, - ListCdnKeysRequest, - ListCdnKeysResponse, - ListLiveAdTagDetailsRequest, - ListLiveAdTagDetailsResponse, - ListLiveConfigsRequest, - ListLiveConfigsResponse, - ListSlatesRequest, - ListSlatesResponse, - ListVodAdTagDetailsRequest, - ListVodAdTagDetailsResponse, - ListVodConfigsRequest, - ListVodConfigsResponse, - ListVodStitchDetailsRequest, - ListVodStitchDetailsResponse, - OperationMetadata, - UpdateCdnKeyRequest, - UpdateLiveConfigRequest, - UpdateSlateRequest, - UpdateVodConfigRequest, -) -from .vod_configs import ( - GamVodConfig, - VodConfig, -) - -__all__ = ( - 'AdRequest', - 'LiveAdTagDetail', - 'RequestMetadata', - 'ResponseMetadata', - 'VodAdTagDetail', - 'AkamaiCdnKey', - 'CdnKey', - 'GoogleCdnKey', - 'MediaCdnKey', - 'Companion', - 'CompanionAds', - 'HtmlAdResource', - 'IframeAdResource', - 'StaticAdResource', - 'Event', - 'ProgressEvent', - 'FetchOptions', - 'GamLiveConfig', - 'LiveConfig', - 'PrefetchConfig', - 'AdTracking', - 'Interstitials', - 'LiveSession', - 'ManifestOptions', - 'RenditionFilter', - 'VodSession', - 'VodSessionAd', - 'VodSessionAdBreak', - 'VodSessionContent', - 'Slate', - 'AdStitchDetail', - 'VodStitchDetail', - 'CreateCdnKeyRequest', - 'CreateLiveConfigRequest', - 'CreateLiveSessionRequest', - 'CreateSlateRequest', - 'CreateVodConfigRequest', - 'CreateVodSessionRequest', - 'DeleteCdnKeyRequest', - 'DeleteLiveConfigRequest', - 'DeleteSlateRequest', - 'DeleteVodConfigRequest', - 'GetCdnKeyRequest', - 'GetLiveAdTagDetailRequest', - 'GetLiveConfigRequest', - 'GetLiveSessionRequest', - 'GetSlateRequest', - 'GetVodAdTagDetailRequest', - 'GetVodConfigRequest', - 'GetVodSessionRequest', - 'GetVodStitchDetailRequest', - 'ListCdnKeysRequest', - 'ListCdnKeysResponse', - 'ListLiveAdTagDetailsRequest', - 'ListLiveAdTagDetailsResponse', - 'ListLiveConfigsRequest', - 'ListLiveConfigsResponse', - 'ListSlatesRequest', - 'ListSlatesResponse', - 'ListVodAdTagDetailsRequest', - 'ListVodAdTagDetailsResponse', - 'ListVodConfigsRequest', - 'ListVodConfigsResponse', - 'ListVodStitchDetailsRequest', - 'ListVodStitchDetailsResponse', - 'OperationMetadata', - 'UpdateCdnKeyRequest', - 'UpdateLiveConfigRequest', - 'UpdateSlateRequest', - 'UpdateVodConfigRequest', - 'GamVodConfig', - 'VodConfig', -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py deleted file mode 100644 index 74ef768b14b4..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/ad_tag_details.py +++ /dev/null @@ -1,180 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 struct_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.video.stitcher.v1', - manifest={ - 'LiveAdTagDetail', - 'VodAdTagDetail', - 'AdRequest', - 'RequestMetadata', - 'ResponseMetadata', - }, -) - - -class LiveAdTagDetail(proto.Message): - r"""Information related to the details for one ad tag. This - resource is only available for live sessions that do not - implement Google Ad Manager ad insertion. - - Attributes: - name (str): - The resource name in the form of - ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{id}``. - ad_requests (MutableSequence[google.cloud.video.stitcher_v1.types.AdRequest]): - A list of ad requests. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - ad_requests: MutableSequence['AdRequest'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='AdRequest', - ) - - -class VodAdTagDetail(proto.Message): - r"""Information related to the details for one ad tag. This - resource is only available for VOD sessions that do not - implement Google Ad Manager ad insertion. - - Attributes: - name (str): - The name of the ad tag detail for the specified VOD session, - in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{id}``. - ad_requests (MutableSequence[google.cloud.video.stitcher_v1.types.AdRequest]): - A list of ad requests for one ad tag. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - ad_requests: MutableSequence['AdRequest'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='AdRequest', - ) - - -class AdRequest(proto.Message): - r"""Details of an ad request to an ad server. - - Attributes: - uri (str): - The ad tag URI processed with integrated - macros. - request_metadata (google.cloud.video.stitcher_v1.types.RequestMetadata): - The request metadata used to make the ad - request. - response_metadata (google.cloud.video.stitcher_v1.types.ResponseMetadata): - The response metadata received from the ad - request. - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - request_metadata: 'RequestMetadata' = proto.Field( - proto.MESSAGE, - number=2, - message='RequestMetadata', - ) - response_metadata: 'ResponseMetadata' = proto.Field( - proto.MESSAGE, - number=3, - message='ResponseMetadata', - ) - - -class RequestMetadata(proto.Message): - r"""Metadata for an ad request. - - Attributes: - headers (google.protobuf.struct_pb2.Struct): - The HTTP headers of the ad request. - """ - - headers: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=1, - message=struct_pb2.Struct, - ) - - -class ResponseMetadata(proto.Message): - r"""Metadata for the response of an ad request. - - Attributes: - error (str): - Error message received when making the ad - request. - headers (google.protobuf.struct_pb2.Struct): - Headers from the response. - status_code (str): - Status code for the response. - size_bytes (int): - Size in bytes of the response. - duration (google.protobuf.duration_pb2.Duration): - Total time elapsed for the response. - body (str): - The body of the response. - """ - - error: str = proto.Field( - proto.STRING, - number=1, - ) - headers: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=2, - message=struct_pb2.Struct, - ) - status_code: str = proto.Field( - proto.STRING, - number=3, - ) - size_bytes: int = proto.Field( - proto.INT32, - number=4, - ) - duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=5, - message=duration_pb2.Duration, - ) - body: str = proto.Field( - proto.STRING, - number=6, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py deleted file mode 100644 index c9cf7e3a0453..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/cdn_keys.py +++ /dev/null @@ -1,182 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher.v1', - manifest={ - 'CdnKey', - 'GoogleCdnKey', - 'AkamaiCdnKey', - 'MediaCdnKey', - }, -) - - -class CdnKey(proto.Message): - r"""Configuration for a CDN key. Used by the Video Stitcher - to sign URIs for fetching video manifests and signing media - segments for playback. - - 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: - google_cdn_key (google.cloud.video.stitcher_v1.types.GoogleCdnKey): - The configuration for a Google Cloud CDN key. - - This field is a member of `oneof`_ ``cdn_key_config``. - akamai_cdn_key (google.cloud.video.stitcher_v1.types.AkamaiCdnKey): - The configuration for an Akamai CDN key. - - This field is a member of `oneof`_ ``cdn_key_config``. - media_cdn_key (google.cloud.video.stitcher_v1.types.MediaCdnKey): - The configuration for a Media CDN key. - - This field is a member of `oneof`_ ``cdn_key_config``. - name (str): - The resource name of the CDN key, in the form of - ``projects/{project}/locations/{location}/cdnKeys/{id}``. - The name is ignored when creating a CDN key. - hostname (str): - The hostname this key applies to. - """ - - google_cdn_key: 'GoogleCdnKey' = proto.Field( - proto.MESSAGE, - number=5, - oneof='cdn_key_config', - message='GoogleCdnKey', - ) - akamai_cdn_key: 'AkamaiCdnKey' = proto.Field( - proto.MESSAGE, - number=6, - oneof='cdn_key_config', - message='AkamaiCdnKey', - ) - media_cdn_key: 'MediaCdnKey' = proto.Field( - proto.MESSAGE, - number=8, - oneof='cdn_key_config', - message='MediaCdnKey', - ) - name: str = proto.Field( - proto.STRING, - number=1, - ) - hostname: str = proto.Field( - proto.STRING, - number=4, - ) - - -class GoogleCdnKey(proto.Message): - r"""Configuration for a Google Cloud CDN key. - - Attributes: - private_key (bytes): - Input only. Secret for this Google Cloud CDN - key. - key_name (str): - The public name of the Google Cloud CDN key. - """ - - private_key: bytes = proto.Field( - proto.BYTES, - number=1, - ) - key_name: str = proto.Field( - proto.STRING, - number=2, - ) - - -class AkamaiCdnKey(proto.Message): - r"""Configuration for an Akamai CDN key. - - Attributes: - token_key (bytes): - Input only. Token key for the Akamai CDN edge - configuration. - """ - - token_key: bytes = proto.Field( - proto.BYTES, - number=1, - ) - - -class MediaCdnKey(proto.Message): - r"""Configuration for a Media CDN key. - - Attributes: - private_key (bytes): - Input only. 64-byte ed25519 private key for - this Media CDN key. - key_name (str): - The keyset name of the Media CDN key. - token_config (google.cloud.video.stitcher_v1.types.MediaCdnKey.TokenConfig): - Optional. If set, the URL will be signed - using the Media CDN token. Otherwise, the URL - would be signed using the standard Media CDN - signature. - """ - - class TokenConfig(proto.Message): - r"""Configuration for a Media CDN token. - - Attributes: - query_parameter (str): - Optional. The query parameter in which to find the token. - - The name must be 1-64 characters long and match the regular - expression ``[a-zA-Z]([a-zA-Z0-9_-])*`` which means the - first character must be a letter, and all following - characters must be a dash, underscore, letter or digit. - - Defaults to ``edge-cache-token``. - """ - - query_parameter: str = proto.Field( - proto.STRING, - number=1, - ) - - private_key: bytes = proto.Field( - proto.BYTES, - number=1, - ) - key_name: str = proto.Field( - proto.STRING, - number=2, - ) - token_config: TokenConfig = proto.Field( - proto.MESSAGE, - number=3, - message=TokenConfig, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py deleted file mode 100644 index 9b5345703e71..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/companions.py +++ /dev/null @@ -1,240 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher_v1.types import events as gcvs_events - - -__protobuf__ = proto.module( - package='google.cloud.video.stitcher.v1', - manifest={ - 'CompanionAds', - 'Companion', - 'HtmlAdResource', - 'IframeAdResource', - 'StaticAdResource', - }, -) - - -class CompanionAds(proto.Message): - r"""Metadata for companion ads. - - Attributes: - display_requirement (google.cloud.video.stitcher_v1.types.CompanionAds.DisplayRequirement): - Indicates how many of the companions should - be displayed with the ad. - companions (MutableSequence[google.cloud.video.stitcher_v1.types.Companion]): - List of companion ads. - """ - class DisplayRequirement(proto.Enum): - r"""Indicates how many of the companions should be displayed with - the ad. - - Values: - DISPLAY_REQUIREMENT_UNSPECIFIED (0): - Required companions are not specified. The - default is ALL. - ALL (1): - All companions are required to be displayed. - ANY (2): - At least one of companions needs to be - displayed. - NONE (3): - All companions are optional for display. - """ - DISPLAY_REQUIREMENT_UNSPECIFIED = 0 - ALL = 1 - ANY = 2 - NONE = 3 - - display_requirement: DisplayRequirement = proto.Field( - proto.ENUM, - number=1, - enum=DisplayRequirement, - ) - companions: MutableSequence['Companion'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='Companion', - ) - - -class Companion(proto.Message): - r"""Metadata for a companion. - - 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: - iframe_ad_resource (google.cloud.video.stitcher_v1.types.IframeAdResource): - The IFrame ad resource associated with the - companion ad. - - This field is a member of `oneof`_ ``ad_resource``. - static_ad_resource (google.cloud.video.stitcher_v1.types.StaticAdResource): - The static ad resource associated with the - companion ad. - - This field is a member of `oneof`_ ``ad_resource``. - html_ad_resource (google.cloud.video.stitcher_v1.types.HtmlAdResource): - The HTML ad resource associated with the - companion ad. - - This field is a member of `oneof`_ ``ad_resource``. - api_framework (str): - The API necessary to communicate with the - creative if available. - height_px (int): - The pixel height of the placement slot for - the intended creative. - width_px (int): - The pixel width of the placement slot for the - intended creative. - asset_height_px (int): - The pixel height of the creative. - expanded_height_px (int): - The maximum pixel height of the creative in - its expanded state. - asset_width_px (int): - The pixel width of the creative. - expanded_width_px (int): - The maximum pixel width of the creative in - its expanded state. - ad_slot_id (str): - The ID used to identify the desired placement - on a publisher's page. Values to be used should - be discussed between publishers and advertisers. - events (MutableSequence[google.cloud.video.stitcher_v1.types.Event]): - The list of tracking events for the - companion. - """ - - iframe_ad_resource: 'IframeAdResource' = proto.Field( - proto.MESSAGE, - number=10, - oneof='ad_resource', - message='IframeAdResource', - ) - static_ad_resource: 'StaticAdResource' = proto.Field( - proto.MESSAGE, - number=11, - oneof='ad_resource', - message='StaticAdResource', - ) - html_ad_resource: 'HtmlAdResource' = proto.Field( - proto.MESSAGE, - number=12, - oneof='ad_resource', - message='HtmlAdResource', - ) - api_framework: str = proto.Field( - proto.STRING, - number=1, - ) - height_px: int = proto.Field( - proto.INT32, - number=2, - ) - width_px: int = proto.Field( - proto.INT32, - number=3, - ) - asset_height_px: int = proto.Field( - proto.INT32, - number=4, - ) - expanded_height_px: int = proto.Field( - proto.INT32, - number=5, - ) - asset_width_px: int = proto.Field( - proto.INT32, - number=6, - ) - expanded_width_px: int = proto.Field( - proto.INT32, - number=7, - ) - ad_slot_id: str = proto.Field( - proto.STRING, - number=8, - ) - events: MutableSequence[gcvs_events.Event] = proto.RepeatedField( - proto.MESSAGE, - number=9, - message=gcvs_events.Event, - ) - - -class HtmlAdResource(proto.Message): - r"""Metadata for an HTML ad resource. - - Attributes: - html_source (str): - The HTML to display for the ad resource. - """ - - html_source: str = proto.Field( - proto.STRING, - number=1, - ) - - -class IframeAdResource(proto.Message): - r"""Metadata for an IFrame ad resource. - - Attributes: - uri (str): - URI source for an IFrame to display for the - ad resource. - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - - -class StaticAdResource(proto.Message): - r"""Metadata for a static ad resource. - - Attributes: - uri (str): - URI to the static file for the ad resource. - creative_type (str): - Describes the MIME type of the ad resource. - """ - - uri: str = proto.Field( - proto.STRING, - number=1, - ) - creative_type: str = proto.Field( - proto.STRING, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py deleted file mode 100644 index 2a21cab7ce8a..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/events.py +++ /dev/null @@ -1,177 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher.v1', - manifest={ - 'Event', - 'ProgressEvent', - }, -) - - -class Event(proto.Message): - r"""Describes an event and a trigger URI. - - Attributes: - type_ (google.cloud.video.stitcher_v1.types.Event.EventType): - Describes the event that occurred. - uri (str): - The URI to trigger for this event. - id (str): - The ID of the event. - offset (google.protobuf.duration_pb2.Duration): - The offset in seconds if the event type is ``PROGRESS``. - """ - class EventType(proto.Enum): - r"""Describes the event that occurred. - - Values: - EVENT_TYPE_UNSPECIFIED (0): - The event type is unspecified. - CREATIVE_VIEW (1): - First frame of creative ad viewed. - START (2): - Creative ad started. - BREAK_START (3): - Start of an ad break. - BREAK_END (4): - End of an ad break. - IMPRESSION (5): - Impression. - FIRST_QUARTILE (6): - First quartile progress. - MIDPOINT (7): - Midpoint progress. - THIRD_QUARTILE (8): - Third quartile progress. - COMPLETE (9): - Ad progress completed. - PROGRESS (10): - Specific progress event with an offset. - MUTE (11): - Player muted. - UNMUTE (12): - Player unmuted. - PAUSE (13): - Player paused. - CLICK (14): - Click event. - CLICK_THROUGH (15): - Click-through event. - REWIND (16): - Player rewinding. - RESUME (17): - Player resumed. - ERROR (18): - Error event. - EXPAND (21): - Ad expanded to a larger size. - COLLAPSE (22): - Ad collapsed to a smaller size. - CLOSE (24): - Non-linear ad closed. - CLOSE_LINEAR (25): - Linear ad closed. - SKIP (26): - Ad skipped. - ACCEPT_INVITATION (27): - Accept invitation event. - """ - EVENT_TYPE_UNSPECIFIED = 0 - CREATIVE_VIEW = 1 - START = 2 - BREAK_START = 3 - BREAK_END = 4 - IMPRESSION = 5 - FIRST_QUARTILE = 6 - MIDPOINT = 7 - THIRD_QUARTILE = 8 - COMPLETE = 9 - PROGRESS = 10 - MUTE = 11 - UNMUTE = 12 - PAUSE = 13 - CLICK = 14 - CLICK_THROUGH = 15 - REWIND = 16 - RESUME = 17 - ERROR = 18 - EXPAND = 21 - COLLAPSE = 22 - CLOSE = 24 - CLOSE_LINEAR = 25 - SKIP = 26 - ACCEPT_INVITATION = 27 - - type_: EventType = proto.Field( - proto.ENUM, - number=1, - enum=EventType, - ) - uri: str = proto.Field( - proto.STRING, - number=2, - ) - id: str = proto.Field( - proto.STRING, - number=3, - ) - offset: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=4, - message=duration_pb2.Duration, - ) - - -class ProgressEvent(proto.Message): - r"""Indicates a time in which a list of events should be - triggered during media playback. - - Attributes: - time_offset (google.protobuf.duration_pb2.Duration): - The time when the following tracking events - occurs. The time is in seconds relative to the - start of the VOD asset. - events (MutableSequence[google.cloud.video.stitcher_v1.types.Event]): - The list of progress tracking events for the ad break. These - can be of the following IAB types: ``BREAK_START``, - ``BREAK_END``, ``IMPRESSION``, ``CREATIVE_VIEW``, ``START``, - ``FIRST_QUARTILE``, ``MIDPOINT``, ``THIRD_QUARTILE``, - ``COMPLETE``, ``PROGRESS``. - """ - - time_offset: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=1, - message=duration_pb2.Duration, - ) - events: MutableSequence['Event'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='Event', - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py deleted file mode 100644 index ecb323aeaede..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/fetch_options.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher.v1', - manifest={ - 'FetchOptions', - }, -) - - -class FetchOptions(proto.Message): - r"""Options on how fetches should be made. - - Attributes: - headers (MutableMapping[str, str]): - Custom headers to pass into fetch request. - Headers must have a maximum of 3 key value - pairs. Each key value pair must have a maximum - of 256 characters per key and 256 characters per - value. - """ - - headers: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py deleted file mode 100644 index 3cd95c03ac2d..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/live_configs.py +++ /dev/null @@ -1,236 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher_v1.types import fetch_options -from google.protobuf import duration_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.video.stitcher.v1', - manifest={ - 'AdTracking', - 'LiveConfig', - 'PrefetchConfig', - 'GamLiveConfig', - }, -) - - -class AdTracking(proto.Enum): - r"""Determines the ad tracking policy. - - Values: - AD_TRACKING_UNSPECIFIED (0): - The ad tracking policy is not specified. - CLIENT (1): - Client-side ad tracking is specified. The - client player is expected to trigger playback - and activity events itself. - SERVER (2): - The Video Stitcher API will trigger playback - events on behalf of the client player. - """ - AD_TRACKING_UNSPECIFIED = 0 - CLIENT = 1 - SERVER = 2 - - -class LiveConfig(proto.Message): - r"""Metadata for used to register live configs. - - Attributes: - name (str): - Output only. The resource name of the live config, in the - form of - ``projects/{project}/locations/{location}/liveConfigs/{id}``. - source_uri (str): - Required. Source URI for the live stream - manifest. - ad_tag_uri (str): - The default ad tag associated with this live - stream config. - gam_live_config (google.cloud.video.stitcher_v1.types.GamLiveConfig): - Additional metadata used to register a live - stream with Google Ad Manager (GAM) - state (google.cloud.video.stitcher_v1.types.LiveConfig.State): - Output only. State of the live config. - ad_tracking (google.cloud.video.stitcher_v1.types.AdTracking): - Required. Determines how the ads are tracked. - default_slate (str): - This must refer to a slate in the same project. If Google Ad - Manager (GAM) is used for ads, this string sets the value of - ``slateCreativeId`` in - https://developers.google.com/ad-manager/api/reference/v202211/LiveStreamEventService.LiveStreamEvent#slateCreativeId - stitching_policy (google.cloud.video.stitcher_v1.types.LiveConfig.StitchingPolicy): - Defines the stitcher behavior in case an ad does not align - exactly with the ad break boundaries. If not specified, the - default is ``CUT_CURRENT``. - prefetch_config (google.cloud.video.stitcher_v1.types.PrefetchConfig): - The configuration for prefetching ads. - source_fetch_options (google.cloud.video.stitcher_v1.types.FetchOptions): - Options for fetching source manifests and - segments. - """ - class State(proto.Enum): - r"""State of the live config. - - Values: - STATE_UNSPECIFIED (0): - State is not specified. - CREATING (1): - Live config is being created. - READY (2): - Live config is ready for use. - DELETING (3): - Live config is queued up for deletion. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - DELETING = 3 - - class StitchingPolicy(proto.Enum): - r"""Defines the ad stitching behavior in case the ad duration does not - align exactly with the ad break boundaries. If not specified, the - default is ``CUT_CURRENT``. - - Values: - STITCHING_POLICY_UNSPECIFIED (0): - Stitching policy is not specified. - CUT_CURRENT (1): - Cuts an ad short and returns to content in - the middle of the ad. - COMPLETE_AD (2): - Finishes stitching the current ad before - returning to content. - """ - STITCHING_POLICY_UNSPECIFIED = 0 - CUT_CURRENT = 1 - COMPLETE_AD = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - source_uri: str = proto.Field( - proto.STRING, - number=2, - ) - ad_tag_uri: str = proto.Field( - proto.STRING, - number=3, - ) - gam_live_config: 'GamLiveConfig' = proto.Field( - proto.MESSAGE, - number=4, - message='GamLiveConfig', - ) - state: State = proto.Field( - proto.ENUM, - number=5, - enum=State, - ) - ad_tracking: 'AdTracking' = proto.Field( - proto.ENUM, - number=6, - enum='AdTracking', - ) - default_slate: str = proto.Field( - proto.STRING, - number=7, - ) - stitching_policy: StitchingPolicy = proto.Field( - proto.ENUM, - number=8, - enum=StitchingPolicy, - ) - prefetch_config: 'PrefetchConfig' = proto.Field( - proto.MESSAGE, - number=10, - message='PrefetchConfig', - ) - source_fetch_options: fetch_options.FetchOptions = proto.Field( - proto.MESSAGE, - number=16, - message=fetch_options.FetchOptions, - ) - - -class PrefetchConfig(proto.Message): - r"""The configuration for prefetch ads. - - Attributes: - enabled (bool): - Required. Indicates whether the option to - prefetch ad requests is enabled. - initial_ad_request_duration (google.protobuf.duration_pb2.Duration): - The duration in seconds of the part of the - break to be prefetched. This field is only - relevant if prefetch is enabled. You should set - this duration to as long as possible to increase - the benefits of prefetching, but not longer than - the shortest ad break expected. For example, for - a live event with 30s and 60s ad breaks, the - initial duration should be set to 30s. - """ - - enabled: bool = proto.Field( - proto.BOOL, - number=1, - ) - initial_ad_request_duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=2, - message=duration_pb2.Duration, - ) - - -class GamLiveConfig(proto.Message): - r"""Metadata used to register a live stream with Google Ad - Manager (GAM) - - Attributes: - network_code (str): - Required. Ad Manager network code to - associate with the live config. - asset_key (str): - Output only. The asset key identifier - generated for the live config. - custom_asset_key (str): - Output only. The custom asset key identifier - generated for the live config. - """ - - network_code: str = proto.Field( - proto.STRING, - number=1, - ) - asset_key: str = proto.Field( - proto.STRING, - number=2, - ) - custom_asset_key: str = proto.Field( - proto.STRING, - number=3, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py deleted file mode 100644 index 55e17f4410c1..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/sessions.py +++ /dev/null @@ -1,452 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher_v1.types import companions -from google.cloud.video.stitcher_v1.types import events -from google.cloud.video.stitcher_v1.types import live_configs -from google.protobuf import duration_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.video.stitcher.v1', - manifest={ - 'VodSession', - 'Interstitials', - 'VodSessionAd', - 'VodSessionContent', - 'VodSessionAdBreak', - 'LiveSession', - 'ManifestOptions', - 'RenditionFilter', - }, -) - - -class VodSession(proto.Message): - r"""Metadata for a VOD session. The session expires 4 hours after - its creation. - - Attributes: - name (str): - Output only. The name of the VOD session, in the form of - ``projects/{project_number}/locations/{location}/vodSessions/{id}``. - interstitials (google.cloud.video.stitcher_v1.types.Interstitials): - Output only. Metadata of what was stitched - into the content. - play_uri (str): - Output only. The playback URI of the stitched - content. - source_uri (str): - URI of the media to stitch. For most use cases, you should - create a - [VodConfig][google.cloud.video.stitcher.v1.VodConfig] with - this information rather than setting this field directly. - ad_tag_uri (str): - Ad tag URI. For most use cases, you should create a - [VodConfig][google.cloud.video.stitcher.v1.VodConfig] with - this information rather than setting this field directly. - ad_tag_macro_map (MutableMapping[str, str]): - Key value pairs for ad tag macro replacement, only available - for VOD sessions that do not implement Google Ad manager ad - insertion. If the specified ad tag URI has macros, this - field provides the mapping to the value that will replace - the macro in the ad tag URI. - - Macros are designated by square brackets, for example: - - Ad tag URI: - ``"https://doubleclick.google.com/ad/1?geo_id=[geoId]"`` - - Ad tag macro map: ``{"geoId": "123"}`` - - Fully qualified ad tag: - ``"https://doubleclick.google.com/ad/1?geo_id=123"`` - manifest_options (google.cloud.video.stitcher_v1.types.ManifestOptions): - Additional options that affect the output of - the manifest. - asset_id (str): - Output only. The generated ID of the - VodSession's source media. - ad_tracking (google.cloud.video.stitcher_v1.types.AdTracking): - Required. Determines how the ad should be - tracked. - gam_settings (google.cloud.video.stitcher_v1.types.VodSession.GamSettings): - This field should be set with appropriate - values if GAM is being used for ads. - vod_config (str): - The resource name of the VOD config for this session, in the - form of - ``projects/{project}/locations/{location}/vodConfigs/{id}``. - """ - - class GamSettings(proto.Message): - r"""Defines fields related to Google Ad Manager (GAM). This - should be set if GAM is being used for ads. - - Attributes: - network_code (str): - Required. Ad Manager network code. - stream_id (str): - Required. The stream ID generated by Ad - Manager. - """ - - network_code: str = proto.Field( - proto.STRING, - number=1, - ) - stream_id: str = proto.Field( - proto.STRING, - number=2, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - interstitials: 'Interstitials' = proto.Field( - proto.MESSAGE, - number=2, - message='Interstitials', - ) - play_uri: str = proto.Field( - proto.STRING, - number=4, - ) - source_uri: str = proto.Field( - proto.STRING, - number=5, - ) - ad_tag_uri: str = proto.Field( - proto.STRING, - number=6, - ) - ad_tag_macro_map: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=7, - ) - manifest_options: 'ManifestOptions' = proto.Field( - proto.MESSAGE, - number=9, - message='ManifestOptions', - ) - asset_id: str = proto.Field( - proto.STRING, - number=10, - ) - ad_tracking: live_configs.AdTracking = proto.Field( - proto.ENUM, - number=11, - enum=live_configs.AdTracking, - ) - gam_settings: GamSettings = proto.Field( - proto.MESSAGE, - number=13, - message=GamSettings, - ) - vod_config: str = proto.Field( - proto.STRING, - number=14, - ) - - -class Interstitials(proto.Message): - r"""Describes what was stitched into a VOD session's manifest. - - Attributes: - ad_breaks (MutableSequence[google.cloud.video.stitcher_v1.types.VodSessionAdBreak]): - List of ad breaks ordered by time. - session_content (google.cloud.video.stitcher_v1.types.VodSessionContent): - Information related to the content of the VOD - session. - """ - - ad_breaks: MutableSequence['VodSessionAdBreak'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='VodSessionAdBreak', - ) - session_content: 'VodSessionContent' = proto.Field( - proto.MESSAGE, - number=2, - message='VodSessionContent', - ) - - -class VodSessionAd(proto.Message): - r"""Metadata for an inserted ad in a VOD session. - - Attributes: - duration (google.protobuf.duration_pb2.Duration): - Duration in seconds of the ad. - companion_ads (google.cloud.video.stitcher_v1.types.CompanionAds): - Metadata of companion ads associated with the - ad. - activity_events (MutableSequence[google.cloud.video.stitcher_v1.types.Event]): - The list of progress tracking events for the ad break. These - can be of the following IAB types: ``MUTE``, ``UNMUTE``, - ``PAUSE``, ``CLICK``, ``CLICK_THROUGH``, ``REWIND``, - ``RESUME``, ``ERROR``, ``FULLSCREEN``, ``EXIT_FULLSCREEN``, - ``EXPAND``, ``COLLAPSE``, ``ACCEPT_INVITATION_LINEAR``, - ``CLOSE_LINEAR``, ``SKIP``. - """ - - duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=1, - message=duration_pb2.Duration, - ) - companion_ads: companions.CompanionAds = proto.Field( - proto.MESSAGE, - number=2, - message=companions.CompanionAds, - ) - activity_events: MutableSequence[events.Event] = proto.RepeatedField( - proto.MESSAGE, - number=3, - message=events.Event, - ) - - -class VodSessionContent(proto.Message): - r"""Metadata for the entire stitched content in a VOD session. - - Attributes: - duration (google.protobuf.duration_pb2.Duration): - The total duration in seconds of the content - including the ads stitched in. - """ - - duration: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=1, - message=duration_pb2.Duration, - ) - - -class VodSessionAdBreak(proto.Message): - r"""Metadata for an inserted ad break. - - Attributes: - progress_events (MutableSequence[google.cloud.video.stitcher_v1.types.ProgressEvent]): - List of events that are expected to be - triggered, ordered by time. - ads (MutableSequence[google.cloud.video.stitcher_v1.types.VodSessionAd]): - Ordered list of ads stitched into the ad - break. - end_time_offset (google.protobuf.duration_pb2.Duration): - Ad break end time in seconds relative to the - start of the VOD asset. - start_time_offset (google.protobuf.duration_pb2.Duration): - Ad break start time in seconds relative to - the start of the VOD asset. - """ - - progress_events: MutableSequence[events.ProgressEvent] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=events.ProgressEvent, - ) - ads: MutableSequence['VodSessionAd'] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message='VodSessionAd', - ) - end_time_offset: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=3, - message=duration_pb2.Duration, - ) - start_time_offset: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=4, - message=duration_pb2.Duration, - ) - - -class LiveSession(proto.Message): - r"""Metadata for a live session. The session expires 5 minutes - after the client stops fetching the session's playlists. - - Attributes: - name (str): - Output only. The name of the live session, in the form of - ``projects/{project}/locations/{location}/liveSessions/{id}``. - play_uri (str): - Output only. The URI to play the live - session's ad-stitched stream. - ad_tag_macros (MutableMapping[str, str]): - Key value pairs for ad tag macro replacement, only available - for live sessions that do not implement Google Ad manager ad - insertion. If the specified ad tag URI has macros, this - field provides the mapping to the value that will replace - the macro in the ad tag URI. - - Macros are designated by square brackets, for example: - - Ad tag URI: - "https://doubleclick.google.com/ad/1?geo_id=[geoId]" - - Ad tag macros: ``{"geoId": "123"}`` - - Fully qualified ad tag: - ``"https://doubleclick.google.com/ad/1?geo_id=123"`` - manifest_options (google.cloud.video.stitcher_v1.types.ManifestOptions): - Additional options that affect the output of - the manifest. - gam_settings (google.cloud.video.stitcher_v1.types.LiveSession.GamSettings): - This field should be set with appropriate - values if GAM is being used for ads. - live_config (str): - Required. The resource name of the live config for this - session, in the form of - ``projects/{project}/locations/{location}/liveConfigs/{id}``. - ad_tracking (google.cloud.video.stitcher_v1.types.AdTracking): - Determines how the ad should be tracked. This - overrides the value set in the live config for - this session. - """ - - class GamSettings(proto.Message): - r"""Defines fields related to Google Ad Manager (GAM). - - Attributes: - stream_id (str): - Required. The stream ID generated by Ad - Manager. This must be set if GAM is being used - for ads and the session uses client-side ad - tracking. - targeting_parameters (MutableMapping[str, str]): - `Targeting - parameters `__ - to send to Ad Manager to generate a stream ID. This should - only be set if the session uses server-side ad tracking. - """ - - stream_id: str = proto.Field( - proto.STRING, - number=1, - ) - targeting_parameters: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=4, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - play_uri: str = proto.Field( - proto.STRING, - number=2, - ) - ad_tag_macros: MutableMapping[str, str] = proto.MapField( - proto.STRING, - proto.STRING, - number=6, - ) - manifest_options: 'ManifestOptions' = proto.Field( - proto.MESSAGE, - number=10, - message='ManifestOptions', - ) - gam_settings: GamSettings = proto.Field( - proto.MESSAGE, - number=15, - message=GamSettings, - ) - live_config: str = proto.Field( - proto.STRING, - number=16, - ) - ad_tracking: live_configs.AdTracking = proto.Field( - proto.ENUM, - number=17, - enum=live_configs.AdTracking, - ) - - -class ManifestOptions(proto.Message): - r"""Options for manifest generation. - - Attributes: - include_renditions (MutableSequence[google.cloud.video.stitcher_v1.types.RenditionFilter]): - If specified, the output manifest will only - return renditions matching the specified - filters. - bitrate_order (google.cloud.video.stitcher_v1.types.ManifestOptions.OrderPolicy): - If specified, the output manifest will orders - the video and muxed renditions by bitrate - according to the ordering policy. - """ - class OrderPolicy(proto.Enum): - r"""Defines the ordering policy during manifest generation. - - Values: - ORDER_POLICY_UNSPECIFIED (0): - Ordering policy is not specified. - ASCENDING (1): - Order by ascending. - DESCENDING (2): - Order by descending. - """ - ORDER_POLICY_UNSPECIFIED = 0 - ASCENDING = 1 - DESCENDING = 2 - - include_renditions: MutableSequence['RenditionFilter'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='RenditionFilter', - ) - bitrate_order: OrderPolicy = proto.Field( - proto.ENUM, - number=2, - enum=OrderPolicy, - ) - - -class RenditionFilter(proto.Message): - r"""Filters for a video or muxed redition. - - Attributes: - bitrate_bps (int): - Bitrate in bits per second for the rendition. - If set, only renditions with the exact bitrate - will match. - codecs (str): - Codecs for the rendition. If set, only - renditions with the exact value will match. - """ - - bitrate_bps: int = proto.Field( - proto.INT32, - number=1, - ) - codecs: str = proto.Field( - proto.STRING, - number=2, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py deleted file mode 100644 index 6966b8630ab0..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/slates.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher.v1', - manifest={ - 'Slate', - }, -) - - -class Slate(proto.Message): - r"""Slate object - - Attributes: - name (str): - Output only. The name of the slate, in the form of - ``projects/{project_number}/locations/{location}/slates/{id}``. - uri (str): - The URI to fetch the source content for the - slate. This URI must return an MP4 video with at - least one audio track. - gam_slate (google.cloud.video.stitcher_v1.types.Slate.GamSlate): - gam_slate has all the GAM-related attributes of slates. - """ - - class GamSlate(proto.Message): - r"""GamSlate object has Google Ad Manager (GAM) related - properties for the slate. - - Attributes: - network_code (str): - Required. Ad Manager network code to - associate with the live config. - gam_slate_id (int): - Output only. The identifier generated for the - slate by GAM. - """ - - network_code: str = proto.Field( - proto.STRING, - number=1, - ) - gam_slate_id: int = proto.Field( - proto.INT64, - number=2, - ) - - name: str = proto.Field( - proto.STRING, - number=1, - ) - uri: str = proto.Field( - proto.STRING, - number=2, - ) - gam_slate: GamSlate = proto.Field( - proto.MESSAGE, - number=3, - message=GamSlate, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py deleted file mode 100644 index 95babe6f6f28..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/stitch_details.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 struct_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.video.stitcher.v1', - manifest={ - 'VodStitchDetail', - 'AdStitchDetail', - }, -) - - -class VodStitchDetail(proto.Message): - r"""Information related to the interstitial of a VOD session. - This resource is only available for VOD sessions that do not - implement Google Ad Manager ad insertion. - - Attributes: - name (str): - The name of the stitch detail in the specified VOD session, - in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. - ad_stitch_details (MutableSequence[google.cloud.video.stitcher_v1.types.AdStitchDetail]): - A list of ad processing details for the - fetched ad playlist. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - ad_stitch_details: MutableSequence['AdStitchDetail'] = proto.RepeatedField( - proto.MESSAGE, - number=3, - message='AdStitchDetail', - ) - - -class AdStitchDetail(proto.Message): - r"""Metadata for a stitched ad. - - Attributes: - ad_break_id (str): - Required. The ad break ID of the processed - ad. - ad_id (str): - Required. The ad ID of the processed ad. - ad_time_offset (google.protobuf.duration_pb2.Duration): - Required. The time offset of the processed - ad. - skip_reason (str): - Optional. Indicates the reason why the ad has - been skipped. - media (MutableMapping[str, google.protobuf.struct_pb2.Value]): - Optional. The metadata of the chosen media - file for the ad. - """ - - ad_break_id: str = proto.Field( - proto.STRING, - number=1, - ) - ad_id: str = proto.Field( - proto.STRING, - number=2, - ) - ad_time_offset: duration_pb2.Duration = proto.Field( - proto.MESSAGE, - number=3, - message=duration_pb2.Duration, - ) - skip_reason: str = proto.Field( - proto.STRING, - number=4, - ) - media: MutableMapping[str, struct_pb2.Value] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=5, - message=struct_pb2.Value, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py deleted file mode 100644 index a2f42edd7cae..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/video_stitcher_service.py +++ /dev/null @@ -1,1124 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys as gcvs_cdn_keys -from google.cloud.video.stitcher_v1.types import live_configs as gcvs_live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates as gcvs_slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import vod_configs as gcvs_vod_configs -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.video.stitcher.v1', - manifest={ - 'CreateCdnKeyRequest', - 'ListCdnKeysRequest', - 'ListCdnKeysResponse', - 'GetCdnKeyRequest', - 'DeleteCdnKeyRequest', - 'UpdateCdnKeyRequest', - 'CreateVodSessionRequest', - 'GetVodSessionRequest', - 'ListVodStitchDetailsRequest', - 'ListVodStitchDetailsResponse', - 'GetVodStitchDetailRequest', - 'ListVodAdTagDetailsRequest', - 'ListVodAdTagDetailsResponse', - 'GetVodAdTagDetailRequest', - 'ListLiveAdTagDetailsRequest', - 'ListLiveAdTagDetailsResponse', - 'GetLiveAdTagDetailRequest', - 'CreateSlateRequest', - 'GetSlateRequest', - 'ListSlatesRequest', - 'ListSlatesResponse', - 'UpdateSlateRequest', - 'DeleteSlateRequest', - 'CreateLiveSessionRequest', - 'GetLiveSessionRequest', - 'CreateLiveConfigRequest', - 'ListLiveConfigsRequest', - 'ListLiveConfigsResponse', - 'GetLiveConfigRequest', - 'DeleteLiveConfigRequest', - 'UpdateLiveConfigRequest', - 'CreateVodConfigRequest', - 'ListVodConfigsRequest', - 'ListVodConfigsResponse', - 'GetVodConfigRequest', - 'DeleteVodConfigRequest', - 'UpdateVodConfigRequest', - 'OperationMetadata', - }, -) - - -class CreateCdnKeyRequest(proto.Message): - r"""Request message for VideoStitcherService.createCdnKey. - - Attributes: - parent (str): - Required. The project in which the CDN key should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): - Required. The CDN key resource to create. - cdn_key_id (str): - Required. The ID to use for the CDN key, - which will become the final component of the CDN - key's resource name. - - This value should conform to RFC-1034, which - restricts to lower-case letters, numbers, and - hyphen, with the first character a letter, the - last a letter or a number, and a 63 character - maximum. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - cdn_key: gcvs_cdn_keys.CdnKey = proto.Field( - proto.MESSAGE, - number=2, - message=gcvs_cdn_keys.CdnKey, - ) - cdn_key_id: str = proto.Field( - proto.STRING, - number=3, - ) - - -class ListCdnKeysRequest(proto.Message): - r"""Request message for VideoStitcherService.listCdnKeys. - - Attributes: - parent (str): - Required. The project that contains the list of CDN keys, in - the form of - ``projects/{project_number}/locations/{location}``. - page_size (int): - Requested page size. Server may return fewer - items than requested. If unspecified, server - will pick an appropriate default. - page_token (str): - A token identifying a page of results the - server should return. - filter (str): - Filtering results - order_by (str): - Hint for how to order the results - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListCdnKeysResponse(proto.Message): - r"""Response message for VideoStitcher.ListCdnKeys. - - Attributes: - cdn_keys (MutableSequence[google.cloud.video.stitcher_v1.types.CdnKey]): - List of CDN keys. - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - cdn_keys: MutableSequence[gcvs_cdn_keys.CdnKey] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcvs_cdn_keys.CdnKey, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetCdnKeyRequest(proto.Message): - r"""Request message for VideoStitcherService.getCdnKey. - - Attributes: - name (str): - Required. The name of the CDN key to be retrieved, in the - form of - ``projects/{project}/locations/{location}/cdnKeys/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteCdnKeyRequest(proto.Message): - r"""Request message for VideoStitcherService.deleteCdnKey. - - Attributes: - name (str): - Required. The name of the CDN key to be deleted, in the form - of - ``projects/{project_number}/locations/{location}/cdnKeys/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateCdnKeyRequest(proto.Message): - r"""Request message for VideoStitcherService.updateCdnKey. - - Attributes: - cdn_key (google.cloud.video.stitcher_v1.types.CdnKey): - Required. The CDN key resource which replaces - the resource on the server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - cdn_key: gcvs_cdn_keys.CdnKey = proto.Field( - proto.MESSAGE, - number=1, - message=gcvs_cdn_keys.CdnKey, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class CreateVodSessionRequest(proto.Message): - r"""Request message for VideoStitcherService.createVodSession - - Attributes: - parent (str): - Required. The project and location in which the VOD session - should be created, in the form of - ``projects/{project_number}/locations/{location}``. - vod_session (google.cloud.video.stitcher_v1.types.VodSession): - Required. Parameters for creating a session. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - vod_session: sessions.VodSession = proto.Field( - proto.MESSAGE, - number=2, - message=sessions.VodSession, - ) - - -class GetVodSessionRequest(proto.Message): - r"""Request message for VideoStitcherService.getVodSession - - Attributes: - name (str): - Required. The name of the VOD session to be retrieved, in - the form of - ``projects/{project_number}/locations/{location}/vodSessions/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListVodStitchDetailsRequest(proto.Message): - r"""Request message for - VideoStitcherService.listVodStitchDetails. - - Attributes: - parent (str): - Required. The VOD session where the stitch details belong - to, in the form of - ``projects/{project}/locations/{location}/vodSessions/{id}``. - page_size (int): - The maximum number of items to return. - page_token (str): - The next_page_token value returned from a previous List - request, if any. - """ - - 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 ListVodStitchDetailsResponse(proto.Message): - r"""Response message for - VideoStitcherService.listVodStitchDetails. - - Attributes: - vod_stitch_details (MutableSequence[google.cloud.video.stitcher_v1.types.VodStitchDetail]): - A List of stitch Details. - next_page_token (str): - The pagination token. - """ - - @property - def raw_page(self): - return self - - vod_stitch_details: MutableSequence[stitch_details.VodStitchDetail] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=stitch_details.VodStitchDetail, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetVodStitchDetailRequest(proto.Message): - r"""Request message for VideoStitcherService.getVodStitchDetail. - - Attributes: - name (str): - Required. The name of the stitch detail in the specified VOD - session, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodStitchDetails/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListVodAdTagDetailsRequest(proto.Message): - r"""Request message for VideoStitcherService.listVodAdTagDetails. - - Attributes: - parent (str): - Required. The VOD session which the ad tag details belong - to, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}``. - page_size (int): - The maximum number of items to return. - page_token (str): - The next_page_token value returned from a previous List - request, if any. - """ - - 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 ListVodAdTagDetailsResponse(proto.Message): - r"""Response message for - VideoStitcherService.listVodAdTagDetails. - - Attributes: - vod_ad_tag_details (MutableSequence[google.cloud.video.stitcher_v1.types.VodAdTagDetail]): - A List of ad tag details. - next_page_token (str): - The pagination token. - """ - - @property - def raw_page(self): - return self - - vod_ad_tag_details: MutableSequence[ad_tag_details.VodAdTagDetail] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=ad_tag_details.VodAdTagDetail, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetVodAdTagDetailRequest(proto.Message): - r"""Request message for VideoStitcherService.getVodAdTagDetail - - Attributes: - name (str): - Required. The name of the ad tag detail for the specified - VOD session, in the form of - ``projects/{project}/locations/{location}/vodSessions/{vod_session_id}/vodAdTagDetails/{vod_ad_tag_detail}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListLiveAdTagDetailsRequest(proto.Message): - r"""Request message for - VideoStitcherService.listLiveAdTagDetails. - - Attributes: - parent (str): - Required. The resource parent in the form of - ``projects/{project}/locations/{location}/liveSessions/{live_session}``. - page_size (int): - The maximum number of items to return. - page_token (str): - The pagination token 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 ListLiveAdTagDetailsResponse(proto.Message): - r"""Response message for - VideoStitcherService.listLiveAdTagDetails. - - Attributes: - live_ad_tag_details (MutableSequence[google.cloud.video.stitcher_v1.types.LiveAdTagDetail]): - A list of live session ad tag details. - next_page_token (str): - The pagination token. - """ - - @property - def raw_page(self): - return self - - live_ad_tag_details: MutableSequence[ad_tag_details.LiveAdTagDetail] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=ad_tag_details.LiveAdTagDetail, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetLiveAdTagDetailRequest(proto.Message): - r"""Request message for VideoStitcherService.getLiveAdTagDetail - - Attributes: - name (str): - Required. The resource name in the form of - ``projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateSlateRequest(proto.Message): - r"""Request message for VideoStitcherService.createSlate. - - Attributes: - parent (str): - Required. The project in which the slate should be created, - in the form of - ``projects/{project_number}/locations/{location}``. - slate_id (str): - Required. The unique identifier for the - slate. This value should conform to RFC-1034, - which restricts to lower-case letters, numbers, - and hyphen, with the first character a letter, - the last a letter or a number, and a 63 - character maximum. - slate (google.cloud.video.stitcher_v1.types.Slate): - Required. The slate to create. - request_id (str): - A request ID to identify requests. Specify a unique request - ID so that if you must retry your request, the server will - know to ignore the request if it has already been completed. - The server will guarantee that for at least 60 minutes since - the first request. - - For example, consider a situation where you make an initial - request and the request times out. If you make the request - again with the same request ID, the server can check if - original operation with the same request ID was received, - and if so, will ignore the second request. This prevents - clients from accidentally creating duplicate commitments. - - The request ID must be a valid UUID with the exception that - zero UUID is not supported - ``(00000000-0000-0000-0000-000000000000)``. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - slate_id: str = proto.Field( - proto.STRING, - number=2, - ) - slate: gcvs_slates.Slate = proto.Field( - proto.MESSAGE, - number=3, - message=gcvs_slates.Slate, - ) - request_id: str = proto.Field( - proto.STRING, - number=4, - ) - - -class GetSlateRequest(proto.Message): - r"""Request message for VideoStitcherService.getSlate. - - Attributes: - name (str): - Required. The name of the slate to be retrieved, of the - slate, in the form of - ``projects/{project_number}/locations/{location}/slates/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class ListSlatesRequest(proto.Message): - r"""Request message for VideoStitcherService.listSlates. - - Attributes: - parent (str): - Required. The project to list slates, in the form of - ``projects/{project_number}/locations/{location}``. - page_size (int): - Requested page size. Server may return fewer - items than requested. If unspecified, server - will pick an appropriate default. - page_token (str): - A token identifying a page of results the - server should return. - filter (str): - Filtering results - order_by (str): - Hint for how to order the results - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListSlatesResponse(proto.Message): - r"""Response message for VideoStitcherService.listSlates. - - Attributes: - slates (MutableSequence[google.cloud.video.stitcher_v1.types.Slate]): - The list of slates - next_page_token (str): - A token identifying a page of results the - server should return. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - slates: MutableSequence[gcvs_slates.Slate] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcvs_slates.Slate, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class UpdateSlateRequest(proto.Message): - r"""Request message for VideoStitcherService.updateSlate. - - Attributes: - slate (google.cloud.video.stitcher_v1.types.Slate): - Required. The resource with updated fields. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask which specifies - fields which should be updated. - """ - - slate: gcvs_slates.Slate = proto.Field( - proto.MESSAGE, - number=1, - message=gcvs_slates.Slate, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class DeleteSlateRequest(proto.Message): - r"""Request message for VideoStitcherService.deleteSlate. - - Attributes: - name (str): - Required. The name of the slate to be deleted, in the form - of - ``projects/{project_number}/locations/{location}/slates/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateLiveSessionRequest(proto.Message): - r"""Request message for VideoStitcherService.createLiveSession. - - Attributes: - parent (str): - Required. The project and location in which the live session - should be created, in the form of - ``projects/{project_number}/locations/{location}``. - live_session (google.cloud.video.stitcher_v1.types.LiveSession): - Required. Parameters for creating a live - session. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - live_session: sessions.LiveSession = proto.Field( - proto.MESSAGE, - number=2, - message=sessions.LiveSession, - ) - - -class GetLiveSessionRequest(proto.Message): - r"""Request message for VideoStitcherService.getSession. - - Attributes: - name (str): - Required. The name of the live session, in the form of - ``projects/{project_number}/locations/{location}/liveSessions/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateLiveConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.createLiveConfig - - Attributes: - parent (str): - Required. The project in which the live config should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - live_config_id (str): - Required. The unique identifier ID to use for - the live config. - live_config (google.cloud.video.stitcher_v1.types.LiveConfig): - Required. The live config resource to create. - request_id (str): - A request ID to identify requests. Specify a unique request - ID so that if you must retry your request, the server will - know to ignore the request if it has already been completed. - The server will guarantee that for at least 60 minutes since - the first request. - - For example, consider a situation where you make an initial - request and the request times out. If you make the request - again with the same request ID, the server can check if - original operation with the same request ID was received, - and if so, will ignore the second request. This prevents - clients from accidentally creating duplicate commitments. - - The request ID must be a valid UUID with the exception that - zero UUID is not supported - ``(00000000-0000-0000-0000-000000000000)``. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - live_config_id: str = proto.Field( - proto.STRING, - number=2, - ) - live_config: gcvs_live_configs.LiveConfig = proto.Field( - proto.MESSAGE, - number=3, - message=gcvs_live_configs.LiveConfig, - ) - request_id: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListLiveConfigsRequest(proto.Message): - r"""Request message for VideoStitcherService.listLiveConfig. - - Attributes: - parent (str): - Required. The project that contains the list of live - configs, in the form of - ``projects/{project_number}/locations/{location}``. - page_size (int): - The maximum number of items to return. - page_token (str): - The next_page_token value returned from a previous List - request, if any. - filter (str): - Optional. The filter to apply to list results (see - `Filtering `__). - order_by (str): - Optional. Specifies the ordering of results following `Cloud - API - syntax `__. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListLiveConfigsResponse(proto.Message): - r"""Response message for VideoStitcher.ListLiveConfig. - - Attributes: - live_configs (MutableSequence[google.cloud.video.stitcher_v1.types.LiveConfig]): - List of live configs. - next_page_token (str): - The pagination token. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - live_configs: MutableSequence[gcvs_live_configs.LiveConfig] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcvs_live_configs.LiveConfig, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetLiveConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.getLiveConfig. - - Attributes: - name (str): - Required. The name of the live config to be retrieved, in - the form of - ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteLiveConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.deleteLiveConfig. - - Attributes: - name (str): - Required. The name of the live config to be deleted, in the - form of - ``projects/{project_number}/locations/{location}/liveConfigs/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateLiveConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.updateLiveConfig. - - Attributes: - live_config (google.cloud.video.stitcher_v1.types.LiveConfig): - Required. The LiveConfig resource which - replaces the resource on the server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - live_config: gcvs_live_configs.LiveConfig = proto.Field( - proto.MESSAGE, - number=1, - message=gcvs_live_configs.LiveConfig, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class CreateVodConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.createVodConfig - - Attributes: - parent (str): - Required. The project in which the VOD config should be - created, in the form of - ``projects/{project_number}/locations/{location}``. - vod_config_id (str): - Required. The unique identifier ID to use for - the VOD config. - vod_config (google.cloud.video.stitcher_v1.types.VodConfig): - Required. The VOD config resource to create. - request_id (str): - Optional. A request ID to identify requests. Specify a - unique request ID so that if you must retry your request, - the server will know to ignore the request if it has already - been completed. The server will guarantee that for at least - 60 minutes since the first request. - - For example, consider a situation where you make an initial - request and the request times out. If you make the request - again with the same request ID, the server can check if - original operation with the same request ID was received, - and if so, will ignore the second request. This prevents - clients from accidentally creating duplicate commitments. - - The request ID must be a valid UUID with the exception that - zero UUID is not supported - ``(00000000-0000-0000-0000-000000000000)``. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - vod_config_id: str = proto.Field( - proto.STRING, - number=2, - ) - vod_config: gcvs_vod_configs.VodConfig = proto.Field( - proto.MESSAGE, - number=3, - message=gcvs_vod_configs.VodConfig, - ) - request_id: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListVodConfigsRequest(proto.Message): - r"""Request message for VideoStitcherService.listVodConfig. - - Attributes: - parent (str): - Required. The project that contains the list of VOD configs, - in the form of - ``projects/{project_number}/locations/{location}``. - page_size (int): - Optional. The maximum number of items to - return. - page_token (str): - Optional. The next_page_token value returned from a previous - List request, if any. - filter (str): - Optional. The filter to apply to list results (see - `Filtering `__). - order_by (str): - Optional. Specifies the ordering of results following `Cloud - API - syntax `__. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - page_size: int = proto.Field( - proto.INT32, - number=2, - ) - page_token: str = proto.Field( - proto.STRING, - number=3, - ) - filter: str = proto.Field( - proto.STRING, - number=4, - ) - order_by: str = proto.Field( - proto.STRING, - number=5, - ) - - -class ListVodConfigsResponse(proto.Message): - r"""Response message for VideoStitcher.ListVodConfig. - - Attributes: - vod_configs (MutableSequence[google.cloud.video.stitcher_v1.types.VodConfig]): - List of VOD configs. - next_page_token (str): - The pagination token. - unreachable (MutableSequence[str]): - Locations that could not be reached. - """ - - @property - def raw_page(self): - return self - - vod_configs: MutableSequence[gcvs_vod_configs.VodConfig] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message=gcvs_vod_configs.VodConfig, - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - unreachable: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=3, - ) - - -class GetVodConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.getVodConfig. - - Attributes: - name (str): - Required. The name of the VOD config to be retrieved, in the - form of - ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class DeleteVodConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.deleteVodConfig. - - Attributes: - name (str): - Required. The name of the VOD config to be deleted, in the - form of - ``projects/{project_number}/locations/{location}/vodConfigs/{id}``. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class UpdateVodConfigRequest(proto.Message): - r"""Request message for VideoStitcherService.updateVodConfig. - - Attributes: - vod_config (google.cloud.video.stitcher_v1.types.VodConfig): - Required. The VOD config resource which - replaces the resource on the server. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. The update mask applies to the resource. For the - ``FieldMask`` definition, see - https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - """ - - vod_config: gcvs_vod_configs.VodConfig = proto.Field( - proto.MESSAGE, - number=1, - message=gcvs_vod_configs.VodConfig, - ) - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=2, - message=field_mask_pb2.FieldMask, - ) - - -class OperationMetadata(proto.Message): - r"""Represents the metadata of the long-running operation. - - Attributes: - create_time (google.protobuf.timestamp_pb2.Timestamp): - The time the operation was created. - end_time (google.protobuf.timestamp_pb2.Timestamp): - The time the operation finished running. - target (str): - Server-defined resource path for the target - of the operation. - verb (str): - Name of the verb executed by the operation. - """ - - create_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=1, - message=timestamp_pb2.Timestamp, - ) - end_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=2, - message=timestamp_pb2.Timestamp, - ) - target: str = proto.Field( - proto.STRING, - number=3, - ) - verb: str = proto.Field( - proto.STRING, - number=4, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py b/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py deleted file mode 100644 index be31d4de3b26..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/types/vod_configs.py +++ /dev/null @@ -1,118 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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.video.stitcher_v1.types import fetch_options - - -__protobuf__ = proto.module( - package='google.cloud.video.stitcher.v1', - manifest={ - 'VodConfig', - 'GamVodConfig', - }, -) - - -class VodConfig(proto.Message): - r"""Metadata used to register VOD configs. - - Attributes: - name (str): - Output only. The resource name of the VOD config, in the - form of - ``projects/{project}/locations/{location}/vodConfigs/{id}``. - source_uri (str): - Required. Source URI for the VOD stream - manifest. - ad_tag_uri (str): - Required. The default ad tag associated with - this VOD config. - gam_vod_config (google.cloud.video.stitcher_v1.types.GamVodConfig): - Optional. Google Ad Manager (GAM) metadata. - state (google.cloud.video.stitcher_v1.types.VodConfig.State): - Output only. State of the VOD config. - source_fetch_options (google.cloud.video.stitcher_v1.types.FetchOptions): - Options for fetching source manifests and - segments. - """ - class State(proto.Enum): - r"""State of the VOD config. - - Values: - STATE_UNSPECIFIED (0): - State is not specified. - CREATING (1): - VOD config is being created. - READY (2): - VOD config is ready for use. - DELETING (3): - VOD config is queued up for deletion. - """ - STATE_UNSPECIFIED = 0 - CREATING = 1 - READY = 2 - DELETING = 3 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - source_uri: str = proto.Field( - proto.STRING, - number=2, - ) - ad_tag_uri: str = proto.Field( - proto.STRING, - number=3, - ) - gam_vod_config: 'GamVodConfig' = proto.Field( - proto.MESSAGE, - number=4, - message='GamVodConfig', - ) - state: State = proto.Field( - proto.ENUM, - number=5, - enum=State, - ) - source_fetch_options: fetch_options.FetchOptions = proto.Field( - proto.MESSAGE, - number=8, - message=fetch_options.FetchOptions, - ) - - -class GamVodConfig(proto.Message): - r"""Metadata used for GAM ad decisioning. - - Attributes: - network_code (str): - Required. Ad Manager network code to - associate with the VOD config. - """ - - network_code: str = proto.Field( - proto.STRING, - number=1, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini b/owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini deleted file mode 100644 index 574c5aed394b..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py b/owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py deleted file mode 100644 index 2f49beb21277..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/noxfile.py +++ /dev/null @@ -1,591 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -import pathlib -import re -import shutil - -from typing import Dict, List -import warnings - -import nox - -BLACK_VERSION = "black[jupyter]==23.7.0" -ISORT_VERSION = "isort==5.11.0" - -LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", - "3.11", - "3.12", - "3.13", -] - -DEFAULT_PYTHON_VERSION = ALL_PYTHON[-1] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = "google-cloud-video-stitcher" - -UNIT_TEST_STANDARD_DEPENDENCIES = [ - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", -] -UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] -UNIT_TEST_LOCAL_DEPENDENCIES: List[str] = [] -UNIT_TEST_DEPENDENCIES: List[str] = [] -UNIT_TEST_EXTRAS: List[str] = [] -UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} - -SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] -SYSTEM_TEST_STANDARD_DEPENDENCIES = [ - "mock", - "pytest", - "google-cloud-testutils", -] -SYSTEM_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] -SYSTEM_TEST_LOCAL_DEPENDENCIES: List[str] = [] -SYSTEM_TEST_DEPENDENCIES: List[str] = [] -SYSTEM_TEST_EXTRAS: List[str] = [] -SYSTEM_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {} - -nox.options.sessions = [ - "unit", - "system", - "cover", - "lint", - "lint_setup_py", - "blacken", - "docs", -] - -# Error if a python version is missing -nox.options.error_on_missing_interpreters = True - - -@nox.session(python=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install( - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2410): Use the latest version of mypy - "mypy<1.16.0", - "types-requests", - "types-protobuf", - ) - session.install(".") - session.run( - "mypy", - "-p", - "google", - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install("google-cloud-testutils") - session.install(".") - - session.run( - "lower-bound-checker", - "update", - "--package-name", - PACKAGE_NAME, - "--constraints-file", - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install("google-cloud-testutils") - session.install(".") - - session.run( - "lower-bound-checker", - "check", - "--package-name", - PACKAGE_NAME, - "--constraints-file", - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *LINT_PATHS, - ) - - session.run("flake8", "google", "tests") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *LINT_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def format(session): - """ - Run isort to sort imports. Then run black - to format code to uniform standard. - """ - session.install(BLACK_VERSION, ISORT_VERSION) - # Use the --fss option to sort imports using strict alphabetical order. - # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections - session.run( - "isort", - "--fss", - *LINT_PATHS, - ) - session.run( - "black", - *LINT_PATHS, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint_setup_py(session): - """Verify that setup.py is valid (including RST check).""" - session.install("setuptools", "docutils", "pygments") - session.run("python", "setup.py", "check", "--restructuredtext", "--strict") - - -def install_unittest_dependencies(session, *constraints): - standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES - session.install(*standard_deps, *constraints) - - if UNIT_TEST_EXTERNAL_DEPENDENCIES: - warnings.warn( - "'unit_test_external_dependencies' is deprecated. Instead, please " - "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", - DeprecationWarning, - ) - session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) - - if UNIT_TEST_LOCAL_DEPENDENCIES: - session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) - - if UNIT_TEST_EXTRAS_BY_PYTHON: - extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) - elif UNIT_TEST_EXTRAS: - extras = UNIT_TEST_EXTRAS - else: - extras = [] - - if extras: - session.install("-e", f".[{','.join(extras)}]", *constraints) - else: - session.install("-e", ".", *constraints) - - -@nox.session(python=ALL_PYTHON) -@nox.parametrize( - "protobuf_implementation", - ["python", "upb", "cpp"], -) -def unit(session, protobuf_implementation): - # Install all test dependencies, then install this package in-place. - - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): - session.skip("cpp implementation is not supported in python 3.11+") - - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - install_unittest_dependencies(session, "-c", constraints_path) - - # TODO(https://github.com/googleapis/synthtool/issues/1976): - # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. - # The 'cpp' implementation requires Protobuf<4. - if protobuf_implementation == "cpp": - session.install("protobuf<4") - - # Run py.test against the unit tests. - session.run( - "py.test", - "--quiet", - f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google", - "--cov=tests/unit", - "--cov-append", - "--cov-config=.coveragerc", - "--cov-report=", - "--cov-fail-under=0", - os.path.join("tests", "unit"), - *session.posargs, - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - - -def install_systemtest_dependencies(session, *constraints): - session.install("--pre", "grpcio") - - session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: - session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_LOCAL_DEPENDENCIES: - session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_DEPENDENCIES: - session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) - - if SYSTEM_TEST_EXTRAS_BY_PYTHON: - extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) - elif SYSTEM_TEST_EXTRAS: - extras = SYSTEM_TEST_EXTRAS - else: - extras = [] - - if extras: - session.install("-e", f".[{','.join(extras)}]", *constraints) - else: - session.install("-e", ".", *constraints) - - -@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) -def system(session): - """Run the system test suite.""" - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. - if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": - session.skip("RUN_SYSTEM_TESTS is set to false, skipping") - # Install pyopenssl for mTLS testing. - if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": - session.install("pyopenssl") - - system_test_exists = os.path.exists(system_test_path) - system_test_folder_exists = os.path.exists(system_test_folder_path) - # Sanity check: only run tests if found. - if not system_test_exists and not system_test_folder_exists: - session.skip("System tests were not found") - - install_systemtest_dependencies(session, "-c", constraints_path) - - # Run py.test against the system tests. - if system_test_exists: - session.run( - "py.test", - "--quiet", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if system_test_folder_exists: - session.run( - "py.test", - "--quiet", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def cover(session): - """Run the final coverage report. - - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python="3.10") -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install( - # We need to pin to specific versions of the `sphinxcontrib-*` packages - # which still support sphinx 4.x. - # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 - # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. - "sphinxcontrib-applehelp==1.0.4", - "sphinxcontrib-devhelp==1.0.2", - "sphinxcontrib-htmlhelp==2.0.1", - "sphinxcontrib-qthelp==1.0.3", - "sphinxcontrib-serializinghtml==1.1.5", - "sphinx==4.5.0", - "alabaster", - "recommonmark", - ) - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", "html", # builder - "-d", os.path.join("docs", "_build", "doctrees", ""), # cache directory - # paths to build: - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python="3.10") -def docfx(session): - """Build the docfx yaml files for this library.""" - - session.install("-e", ".") - session.install( - # We need to pin to specific versions of the `sphinxcontrib-*` packages - # which still support sphinx 4.x. - # See https://github.com/googleapis/sphinx-docfx-yaml/issues/344 - # and https://github.com/googleapis/sphinx-docfx-yaml/issues/345. - "sphinxcontrib-applehelp==1.0.4", - "sphinxcontrib-devhelp==1.0.2", - "sphinxcontrib-htmlhelp==2.0.1", - "sphinxcontrib-qthelp==1.0.3", - "sphinxcontrib-serializinghtml==1.1.5", - "gcp-sphinx-docfx-yaml", - "alabaster", - "recommonmark", - ) - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-T", # show full traceback on exception - "-N", # no colors - "-D", - ( - "extensions=sphinx.ext.autodoc," - "sphinx.ext.autosummary," - "docfx_yaml.extension," - "sphinx.ext.intersphinx," - "sphinx.ext.coverage," - "sphinx.ext.napoleon," - "sphinx.ext.todo," - "sphinx.ext.viewcode," - "recommonmark" - ), - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -@nox.parametrize( - "protobuf_implementation", - ["python", "upb", "cpp"], -) -def prerelease_deps(session, protobuf_implementation): - """ - Run all tests with pre-release versions of dependencies installed - rather than the standard non pre-release versions. - Pre-release versions can be installed using - `pip install --pre `. - """ - - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): - session.skip("cpp implementation is not supported in python 3.11+") - - # Install all dependencies - session.install("-e", ".") - - # Install dependencies for the unit test environment - unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES - session.install(*unit_deps_all) - - # Install dependencies for the system test environment - system_deps_all = ( - SYSTEM_TEST_STANDARD_DEPENDENCIES - + SYSTEM_TEST_EXTERNAL_DEPENDENCIES - + SYSTEM_TEST_EXTRAS - ) - session.install(*system_deps_all) - - # Because we test minimum dependency versions on the minimum Python - # version, the first version we test with in the unit tests sessions has a - # constraints file containing all dependencies and extras. - with open( - CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_PYTHON[0]}.txt", - encoding="utf-8", - ) as constraints_file: - constraints_text = constraints_file.read() - - # Ignore leading whitespace and comment lines. - constraints_deps = [ - match.group(1) - for match in re.finditer( - r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE - ) - ] - - # Install dependencies specified in `testing/constraints-X.txt`. - session.install(*constraints_deps) - - # Note: If a dependency is added to the `prerel_deps` list, - # the `core_dependencies_from_source` list in the `core_deps_from_source` - # nox session should also be updated. - prerel_deps = [ - "googleapis-common-protos", - "google-api-core", - "google-auth", - "grpc-google-iam-v1", - "grpcio", - "grpcio-status", - "protobuf", - "proto-plus", - ] - - for dep in prerel_deps: - session.install("--pre", "--no-deps", "--ignore-installed", dep) - # TODO(https://github.com/grpc/grpc/issues/38965): Add `grpcio-status`` - # to the dictionary below once this bug is fixed. - # TODO(https://github.com/googleapis/google-cloud-python/issues/13643): Add - # `googleapis-common-protos` and `grpc-google-iam-v1` to the dictionary below - # once this bug is fixed. - package_namespaces = { - "google-api-core": "google.api_core", - "google-auth": "google.auth", - "grpcio": "grpc", - "protobuf": "google.protobuf", - "proto-plus": "proto", - } - - version_namespace = package_namespaces.get(dep) - - print(f"Installed {dep}") - if version_namespace: - session.run( - "python", - "-c", - f"import {version_namespace}; print({version_namespace}.__version__)", - ) - - session.run( - "py.test", - "tests/unit", - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -@nox.parametrize( - "protobuf_implementation", - ["python", "upb"], -) -def core_deps_from_source(session, protobuf_implementation): - """Run all tests with core dependencies installed from source - rather than pulling the dependencies from PyPI. - """ - - # Install all dependencies - session.install("-e", ".") - - # Install dependencies for the unit test environment - unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES - session.install(*unit_deps_all) - - # Install dependencies for the system test environment - system_deps_all = ( - SYSTEM_TEST_STANDARD_DEPENDENCIES - + SYSTEM_TEST_EXTERNAL_DEPENDENCIES - + SYSTEM_TEST_EXTRAS - ) - session.install(*system_deps_all) - - # Because we test minimum dependency versions on the minimum Python - # version, the first version we test with in the unit tests sessions has a - # constraints file containing all dependencies and extras. - with open( - CURRENT_DIRECTORY / "testing" / f"constraints-{ALL_PYTHON[0]}.txt", - encoding="utf-8", - ) as constraints_file: - constraints_text = constraints_file.read() - - # Ignore leading whitespace and comment lines. - constraints_deps = [ - match.group(1) - for match in re.finditer( - r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE - ) - ] - - # Install dependencies specified in `testing/constraints-X.txt`. - session.install(*constraints_deps) - - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2358): `grpcio` and - # `grpcio-status` should be added to the list below so that they are installed from source, - # rather than PyPI. - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2357): `protobuf` should be - # added to the list below so that it is installed from source, rather than PyPI - # Note: If a dependency is added to the `core_dependencies_from_source` list, - # the `prerel_deps` list in the `prerelease_deps` nox session should also be updated. - core_dependencies_from_source = [ - "googleapis-common-protos @ git+https://github.com/googleapis/google-cloud-python#egg=googleapis-common-protos&subdirectory=packages/googleapis-common-protos", - "google-api-core @ git+https://github.com/googleapis/python-api-core.git", - "google-auth @ git+https://github.com/googleapis/google-auth-library-python.git", - "grpc-google-iam-v1 @ git+https://github.com/googleapis/google-cloud-python#egg=grpc-google-iam-v1&subdirectory=packages/grpc-google-iam-v1", - "proto-plus @ git+https://github.com/googleapis/proto-plus-python.git", - ] - - for dep in core_dependencies_from_source: - session.install(dep, "--no-deps", "--ignore-installed") - print(f"Installed {dep}") - - session.run( - "py.test", - "tests/unit", - env={ - "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, - }, - ) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json deleted file mode 100644 index 2e9dbfeedb7e..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/snippet_metadata_google.cloud.video.stitcher.v1.json +++ /dev/null @@ -1,4957 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.cloud.video.stitcher.v1", - "version": "v1" - } - ], - "language": "PYTHON", - "name": "google-cloud-video-stitcher", - "version": "0.1.0" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "cdn_key", - "type": "google.cloud.video.stitcher_v1.types.CdnKey" - }, - { - "name": "cdn_key_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_cdn_key" - }, - "description": "Sample for CreateCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_async", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateCdnKeyRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "cdn_key", - "type": "google.cloud.video.stitcher_v1.types.CdnKey" - }, - { - "name": "cdn_key_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_cdn_key" - }, - "description": "Sample for CreateCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_sync", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "live_config", - "type": "google.cloud.video.stitcher_v1.types.LiveConfig" - }, - { - "name": "live_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_live_config" - }, - "description": "Sample for CreateLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_async", - "segments": [ - { - "end": 61, - "start": 27, - "type": "FULL" - }, - { - "end": 61, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 58, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 62, - "start": 59, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateLiveConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "live_config", - "type": "google.cloud.video.stitcher_v1.types.LiveConfig" - }, - { - "name": "live_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_live_config" - }, - "description": "Sample for CreateLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_sync", - "segments": [ - { - "end": 61, - "start": 27, - "type": "FULL" - }, - { - "end": 61, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 58, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 62, - "start": 59, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_live_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateLiveSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "live_session", - "type": "google.cloud.video.stitcher_v1.types.LiveSession" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", - "shortName": "create_live_session" - }, - "description": "Sample for CreateLiveSession", - "file": "videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateLiveSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateLiveSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateLiveSessionRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "live_session", - "type": "google.cloud.video.stitcher_v1.types.LiveSession" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", - "shortName": "create_live_session" - }, - "description": "Sample for CreateLiveSession", - "file": "videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateSlateRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "slate", - "type": "google.cloud.video.stitcher_v1.types.Slate" - }, - { - "name": "slate_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_slate" - }, - "description": "Sample for CreateSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_create_slate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateSlate_async", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_slate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateSlateRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "slate", - "type": "google.cloud.video.stitcher_v1.types.Slate" - }, - { - "name": "slate_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_slate" - }, - "description": "Sample for CreateSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateSlate_sync", - "segments": [ - { - "end": 56, - "start": 27, - "type": "FULL" - }, - { - "end": 56, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 46, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 53, - "start": 47, - "type": "REQUEST_EXECUTION" - }, - { - "end": 57, - "start": 54, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateVodConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "vod_config", - "type": "google.cloud.video.stitcher_v1.types.VodConfig" - }, - { - "name": "vod_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "create_vod_config" - }, - "description": "Sample for CreateVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_async", - "segments": [ - { - "end": 61, - "start": 27, - "type": "FULL" - }, - { - "end": 61, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 58, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 62, - "start": 59, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateVodConfigRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "vod_config", - "type": "google.cloud.video.stitcher_v1.types.VodConfig" - }, - { - "name": "vod_config_id", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "create_vod_config" - }, - "description": "Sample for CreateVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_sync", - "segments": [ - { - "end": 61, - "start": 27, - "type": "FULL" - }, - { - "end": 61, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 51, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 58, - "start": 52, - "type": "REQUEST_EXECUTION" - }, - { - "end": 62, - "start": 59, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.create_vod_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateVodSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateVodSessionRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "vod_session", - "type": "google.cloud.video.stitcher_v1.types.VodSession" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodSession", - "shortName": "create_vod_session" - }, - "description": "Sample for CreateVodSession", - "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodSession_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.CreateVodSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "CreateVodSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.CreateVodSessionRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "vod_session", - "type": "google.cloud.video.stitcher_v1.types.VodSession" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodSession", - "shortName": "create_vod_session" - }, - "description": "Sample for CreateVodSession", - "file": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_CreateVodSession_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_cdn_key" - }, - "description": "Sample for DeleteCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteCdnKeyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_cdn_key" - }, - "description": "Sample for DeleteCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_live_config" - }, - "description": "Sample for DeleteLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteLiveConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_live_config" - }, - "description": "Sample for DeleteLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteSlateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_slate" - }, - "description": "Sample for DeleteSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteSlate_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteSlateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_slate" - }, - "description": "Sample for DeleteSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteSlate_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.delete_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "delete_vod_config" - }, - "description": "Sample for DeleteVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.DeleteVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "DeleteVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.DeleteVodConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "delete_vod_config" - }, - "description": "Sample for DeleteVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetCdnKeyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", - "shortName": "get_cdn_key" - }, - "description": "Sample for GetCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetCdnKey_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetCdnKeyRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.CdnKey", - "shortName": "get_cdn_key" - }, - "description": "Sample for GetCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetCdnKey_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_live_ad_tag_detail", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveAdTagDetail", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetLiveAdTagDetail" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", - "shortName": "get_live_ad_tag_detail" - }, - "description": "Sample for GetLiveAdTagDetail", - "file": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_ad_tag_detail", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveAdTagDetail", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetLiveAdTagDetail" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetLiveAdTagDetailRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveAdTagDetail", - "shortName": "get_live_ad_tag_detail" - }, - "description": "Sample for GetLiveAdTagDetail", - "file": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetLiveConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", - "shortName": "get_live_config" - }, - "description": "Sample for GetLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetLiveConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveConfig", - "shortName": "get_live_config" - }, - "description": "Sample for GetLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_live_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetLiveSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetLiveSessionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", - "shortName": "get_live_session" - }, - "description": "Sample for GetLiveSession", - "file": "videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveSession_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetLiveSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetLiveSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetLiveSessionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.LiveSession", - "shortName": "get_live_session" - }, - "description": "Sample for GetLiveSession", - "file": "videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetLiveSession_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetSlateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.Slate", - "shortName": "get_slate" - }, - "description": "Sample for GetSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_get_slate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetSlate_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_slate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetSlateRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.Slate", - "shortName": "get_slate" - }, - "description": "Sample for GetSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetSlate_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_ad_tag_detail", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodAdTagDetail", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodAdTagDetail" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", - "shortName": "get_vod_ad_tag_detail" - }, - "description": "Sample for GetVodAdTagDetail", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_ad_tag_detail", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodAdTagDetail", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodAdTagDetail" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodAdTagDetailRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodAdTagDetail", - "shortName": "get_vod_ad_tag_detail" - }, - "description": "Sample for GetVodAdTagDetail", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", - "shortName": "get_vod_config" - }, - "description": "Sample for GetVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodConfig_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodConfigRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodConfig", - "shortName": "get_vod_config" - }, - "description": "Sample for GetVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodConfig_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodSessionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodSession", - "shortName": "get_vod_session" - }, - "description": "Sample for GetVodSession", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodSession_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_session", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodSession", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodSession" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodSessionRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodSession", - "shortName": "get_vod_session" - }, - "description": "Sample for GetVodSession", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodSession_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.get_vod_stitch_detail", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodStitchDetail", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodStitchDetail" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", - "shortName": "get_vod_stitch_detail" - }, - "description": "Sample for GetVodStitchDetail", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_async", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_stitch_detail", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.GetVodStitchDetail", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "GetVodStitchDetail" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.GetVodStitchDetailRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.types.VodStitchDetail", - "shortName": "get_vod_stitch_detail" - }, - "description": "Sample for GetVodStitchDetail", - "file": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_sync", - "segments": [ - { - "end": 51, - "start": 27, - "type": "FULL" - }, - { - "end": 51, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 52, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_cdn_keys", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListCdnKeys", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListCdnKeys" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListCdnKeysRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysAsyncPager", - "shortName": "list_cdn_keys" - }, - "description": "Sample for ListCdnKeys", - "file": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_cdn_keys", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListCdnKeys", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListCdnKeys" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListCdnKeysRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListCdnKeysPager", - "shortName": "list_cdn_keys" - }, - "description": "Sample for ListCdnKeys", - "file": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_live_ad_tag_details", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveAdTagDetails", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListLiveAdTagDetails" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsAsyncPager", - "shortName": "list_live_ad_tag_details" - }, - "description": "Sample for ListLiveAdTagDetails", - "file": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_ad_tag_details", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveAdTagDetails", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListLiveAdTagDetails" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListLiveAdTagDetailsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveAdTagDetailsPager", - "shortName": "list_live_ad_tag_details" - }, - "description": "Sample for ListLiveAdTagDetails", - "file": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_live_configs", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveConfigs", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListLiveConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsAsyncPager", - "shortName": "list_live_configs" - }, - "description": "Sample for ListLiveConfigs", - "file": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_configs", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListLiveConfigs", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListLiveConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListLiveConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListLiveConfigsPager", - "shortName": "list_live_configs" - }, - "description": "Sample for ListLiveConfigs", - "file": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_slates", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListSlates", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListSlates" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListSlatesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesAsyncPager", - "shortName": "list_slates" - }, - "description": "Sample for ListSlates", - "file": "videostitcher_v1_generated_video_stitcher_service_list_slates_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListSlates_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_slates_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_slates", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListSlates", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListSlates" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListSlatesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListSlatesPager", - "shortName": "list_slates" - }, - "description": "Sample for ListSlates", - "file": "videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListSlates_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_vod_ad_tag_details", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodAdTagDetails", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListVodAdTagDetails" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsAsyncPager", - "shortName": "list_vod_ad_tag_details" - }, - "description": "Sample for ListVodAdTagDetails", - "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_ad_tag_details", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodAdTagDetails", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListVodAdTagDetails" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListVodAdTagDetailsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodAdTagDetailsPager", - "shortName": "list_vod_ad_tag_details" - }, - "description": "Sample for ListVodAdTagDetails", - "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_vod_configs", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodConfigs", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListVodConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListVodConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsAsyncPager", - "shortName": "list_vod_configs" - }, - "description": "Sample for ListVodConfigs", - "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_configs", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodConfigs", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListVodConfigs" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListVodConfigsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodConfigsPager", - "shortName": "list_vod_configs" - }, - "description": "Sample for ListVodConfigs", - "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.list_vod_stitch_details", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodStitchDetails", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListVodStitchDetails" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsAsyncPager", - "shortName": "list_vod_stitch_details" - }, - "description": "Sample for ListVodStitchDetails", - "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_stitch_details", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.ListVodStitchDetails", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "ListVodStitchDetails" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.ListVodStitchDetailsRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.cloud.video.stitcher_v1.services.video_stitcher_service.pagers.ListVodStitchDetailsPager", - "shortName": "list_vod_stitch_details" - }, - "description": "Sample for ListVodStitchDetails", - "file": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 48, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest" - }, - { - "name": "cdn_key", - "type": "google.cloud.video.stitcher_v1.types.CdnKey" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_cdn_key" - }, - "description": "Sample for UpdateCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_async", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_cdn_key", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateCdnKey", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateCdnKey" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateCdnKeyRequest" - }, - { - "name": "cdn_key", - "type": "google.cloud.video.stitcher_v1.types.CdnKey" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_cdn_key" - }, - "description": "Sample for UpdateCdnKey", - "file": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_sync", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest" - }, - { - "name": "live_config", - "type": "google.cloud.video.stitcher_v1.types.LiveConfig" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_live_config" - }, - "description": "Sample for UpdateLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_async", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_live_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateLiveConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateLiveConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateLiveConfigRequest" - }, - { - "name": "live_config", - "type": "google.cloud.video.stitcher_v1.types.LiveConfig" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_live_config" - }, - "description": "Sample for UpdateLiveConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_sync", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateSlateRequest" - }, - { - "name": "slate", - "type": "google.cloud.video.stitcher_v1.types.Slate" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_slate" - }, - "description": "Sample for UpdateSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_update_slate_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateSlate_async", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_slate_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_slate", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateSlate", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateSlate" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateSlateRequest" - }, - { - "name": "slate", - "type": "google.cloud.video.stitcher_v1.types.Slate" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_slate" - }, - "description": "Sample for UpdateSlate", - "file": "videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateSlate_sync", - "segments": [ - { - "end": 54, - "start": 27, - "type": "FULL" - }, - { - "end": 54, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 44, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 51, - "start": 45, - "type": "REQUEST_EXECUTION" - }, - { - "end": 55, - "start": 52, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient", - "shortName": "VideoStitcherServiceAsyncClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.update_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest" - }, - { - "name": "vod_config", - "type": "google.cloud.video.stitcher_v1.types.VodConfig" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "update_vod_config" - }, - "description": "Sample for UpdateVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_async", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient", - "shortName": "VideoStitcherServiceClient" - }, - "fullName": "google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_vod_config", - "method": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService.UpdateVodConfig", - "service": { - "fullName": "google.cloud.video.stitcher.v1.VideoStitcherService", - "shortName": "VideoStitcherService" - }, - "shortName": "UpdateVodConfig" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.video.stitcher_v1.types.UpdateVodConfigRequest" - }, - { - "name": "vod_config", - "type": "google.cloud.video.stitcher_v1.types.VodConfig" - }, - { - "name": "update_mask", - "type": "google.protobuf.field_mask_pb2.FieldMask" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, Union[str, bytes]]]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "update_vod_config" - }, - "description": "Sample for UpdateVodConfig", - "file": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_sync", - "segments": [ - { - "end": 59, - "start": 27, - "type": "FULL" - }, - { - "end": 59, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 56, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 60, - "start": 57, - "type": "RESPONSE_HANDLING" - } - ], - "title": "videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py" - } - ] -} diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py deleted file mode 100644 index c51d8ee2d3fd..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_create_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateCdnKeyRequest( - parent="parent_value", - cdn_key_id="cdn_key_id_value", - ) - - # Make the request - operation = client.create_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py deleted file mode 100644 index 25a8bb90f12b..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_cdn_key_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_create_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateCdnKeyRequest( - parent="parent_value", - cdn_key_id="cdn_key_id_value", - ) - - # Make the request - operation = client.create_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py deleted file mode 100644 index 5306106cda8e..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_async.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_create_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.CreateLiveConfigRequest( - parent="parent_value", - live_config_id="live_config_id_value", - live_config=live_config, - ) - - # Make the request - operation = client.create_live_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py deleted file mode 100644 index 2f32c4b0ba10..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_config_sync.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_create_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.CreateLiveConfigRequest( - parent="parent_value", - live_config_id="live_config_id_value", - live_config=live_config, - ) - - # Make the request - operation = client.create_live_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py deleted file mode 100644 index d626bf3c595d..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateLiveSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_create_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - live_session = stitcher_v1.LiveSession() - live_session.live_config = "live_config_value" - - request = stitcher_v1.CreateLiveSessionRequest( - parent="parent_value", - live_session=live_session, - ) - - # Make the request - response = await client.create_live_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py deleted file mode 100644 index 98c56f488ac1..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_live_session_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateLiveSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_create_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - live_session = stitcher_v1.LiveSession() - live_session.live_config = "live_config_value" - - request = stitcher_v1.CreateLiveSessionRequest( - parent="parent_value", - live_session=live_session, - ) - - # Make the request - response = client.create_live_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateLiveSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py deleted file mode 100644 index 2d23f2bc7524..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_async.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateSlate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_create_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateSlateRequest( - parent="parent_value", - slate_id="slate_id_value", - ) - - # Make the request - operation = client.create_slate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py deleted file mode 100644 index 257a9c6fd509..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_slate_sync.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateSlate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_create_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.CreateSlateRequest( - parent="parent_value", - slate_id="slate_id_value", - ) - - # Make the request - operation = client.create_slate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py deleted file mode 100644 index 8517f766b866..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_async.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_create_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.CreateVodConfigRequest( - parent="parent_value", - vod_config_id="vod_config_id_value", - vod_config=vod_config, - ) - - # Make the request - operation = client.create_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py deleted file mode 100644 index 641d461c66e7..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_config_sync.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_create_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.CreateVodConfigRequest( - parent="parent_value", - vod_config_id="vod_config_id_value", - vod_config=vod_config, - ) - - # Make the request - operation = client.create_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py deleted file mode 100644 index 9d541de682d4..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateVodSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateVodSession_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_create_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - vod_session = stitcher_v1.VodSession() - vod_session.ad_tracking = "SERVER" - - request = stitcher_v1.CreateVodSessionRequest( - parent="parent_value", - vod_session=vod_session, - ) - - # Make the request - response = await client.create_vod_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateVodSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py deleted file mode 100644 index 0cdffdcdc95f..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_create_vod_session_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for CreateVodSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_CreateVodSession_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_create_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - vod_session = stitcher_v1.VodSession() - vod_session.ad_tracking = "SERVER" - - request = stitcher_v1.CreateVodSessionRequest( - parent="parent_value", - vod_session=vod_session, - ) - - # Make the request - response = client.create_vod_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_CreateVodSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py deleted file mode 100644 index c8e98285da74..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_delete_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteCdnKeyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py deleted file mode 100644 index b63886851fc0..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_cdn_key_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_delete_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteCdnKeyRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py deleted file mode 100644 index 2c64239b7955..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_delete_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteLiveConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_live_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py deleted file mode 100644 index d2383dfe00a5..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_live_config_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_delete_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteLiveConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_live_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py deleted file mode 100644 index 132639b48676..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteSlate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_delete_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteSlateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_slate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py deleted file mode 100644 index 66260563d841..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_slate_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteSlate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_delete_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteSlateRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_slate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py deleted file mode 100644 index a71922a5c802..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_delete_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteVodConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py deleted file mode 100644 index 6f7af4c8b244..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_delete_vod_config_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for DeleteVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_delete_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.DeleteVodConfigRequest( - name="name_value", - ) - - # Make the request - operation = client.delete_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_DeleteVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py deleted file mode 100644 index 9248cceecf70..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetCdnKey_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetCdnKeyRequest( - name="name_value", - ) - - # Make the request - response = await client.get_cdn_key(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py deleted file mode 100644 index c6a684399152..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_cdn_key_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetCdnKey_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetCdnKeyRequest( - name="name_value", - ) - - # Make the request - response = client.get_cdn_key(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py deleted file mode 100644 index 0c7193fc2e6f..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetLiveAdTagDetail -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_live_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = await client.get_live_ad_tag_detail(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py deleted file mode 100644 index 2d3c3758d4fd..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_ad_tag_detail_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetLiveAdTagDetail -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_live_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = client.get_live_ad_tag_detail(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetLiveAdTagDetail_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py deleted file mode 100644 index 0f7d8640947e..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_live_config(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py deleted file mode 100644 index 9fe672785910..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_config_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_live_config(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py deleted file mode 100644 index 05f617f0d762..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetLiveSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetLiveSession_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveSessionRequest( - name="name_value", - ) - - # Make the request - response = await client.get_live_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetLiveSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py deleted file mode 100644 index e00f50782c38..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_live_session_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetLiveSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetLiveSession_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_live_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetLiveSessionRequest( - name="name_value", - ) - - # Make the request - response = client.get_live_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetLiveSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py deleted file mode 100644 index ca869f6067cf..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetSlate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetSlateRequest( - name="name_value", - ) - - # Make the request - response = await client.get_slate(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py deleted file mode 100644 index 47cc4206917e..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_slate_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetSlate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetSlateRequest( - name="name_value", - ) - - # Make the request - response = client.get_slate(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py deleted file mode 100644 index 24bc14bc5aa6..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodAdTagDetail -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_vod_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_ad_tag_detail(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py deleted file mode 100644 index c25aceaf1c3e..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_ad_tag_detail_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodAdTagDetail -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_vod_ad_tag_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodAdTagDetailRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_ad_tag_detail(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodAdTagDetail_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py deleted file mode 100644 index e652f20e8433..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodConfigRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_config(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py deleted file mode 100644 index 080af38ee645..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_config_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodConfigRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_config(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py deleted file mode 100644 index b2f6c6abe203..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodSession_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodSessionRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodSession_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py deleted file mode 100644 index 9cfee64e3bb3..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_session_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodSession -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodSession_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_vod_session(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodSessionRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_session(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodSession_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py deleted file mode 100644 index df8dc4fb1e71..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodStitchDetail -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_get_vod_stitch_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodStitchDetailRequest( - name="name_value", - ) - - # Make the request - response = await client.get_vod_stitch_detail(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py deleted file mode 100644 index 09acbf2e6df5..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_get_vod_stitch_detail_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for GetVodStitchDetail -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_get_vod_stitch_detail(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.GetVodStitchDetailRequest( - name="name_value", - ) - - # Make the request - response = client.get_vod_stitch_detail(request=request) - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_GetVodStitchDetail_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py deleted file mode 100644 index 91a4a5cc28d6..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCdnKeys -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_list_cdn_keys(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListCdnKeysRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_cdn_keys(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py deleted file mode 100644 index 804e5fb686da..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_cdn_keys_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListCdnKeys -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_list_cdn_keys(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListCdnKeysRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_cdn_keys(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListCdnKeys_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py deleted file mode 100644 index 4665b8691317..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListLiveAdTagDetails -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_list_live_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_ad_tag_details(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py deleted file mode 100644 index d5d16ca7d706..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_ad_tag_details_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListLiveAdTagDetails -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_list_live_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_ad_tag_details(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListLiveAdTagDetails_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py deleted file mode 100644 index 2b828784566f..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListLiveConfigs -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_list_live_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py deleted file mode 100644 index 5a44cf5cde09..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_live_configs_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListLiveConfigs -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_list_live_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListLiveConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_live_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListLiveConfigs_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py deleted file mode 100644 index ce62661438cd..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListSlates -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListSlates_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_list_slates(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListSlatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_slates(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListSlates_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py deleted file mode 100644 index 7ce16be126e3..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_slates_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListSlates -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListSlates_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_list_slates(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListSlatesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_slates(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListSlates_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py deleted file mode 100644 index 7c4b1a402dcd..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListVodAdTagDetails -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_list_vod_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_ad_tag_details(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py deleted file mode 100644 index c3cf51689ca4..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_ad_tag_details_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListVodAdTagDetails -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_list_vod_ad_tag_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodAdTagDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_ad_tag_details(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListVodAdTagDetails_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py deleted file mode 100644 index 67e53bbfa8de..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListVodConfigs -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_list_vod_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_configs(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py deleted file mode 100644 index 7f2f0ad278a7..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_configs_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListVodConfigs -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_list_vod_configs(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodConfigsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_configs(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListVodConfigs_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py deleted file mode 100644 index e7cd106a8e74..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListVodStitchDetails -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_list_vod_stitch_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodStitchDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_stitch_details(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py deleted file mode 100644 index 647f195a0317..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_list_vod_stitch_details_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ListVodStitchDetails -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_list_vod_stitch_details(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.ListVodStitchDetailsRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_vod_stitch_details(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_ListVodStitchDetails_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py deleted file mode 100644 index 60a63a672291..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_update_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateCdnKeyRequest( - ) - - # Make the request - operation = client.update_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py deleted file mode 100644 index ce8e5b3d2bc8..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_cdn_key_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateCdnKey -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_update_cdn_key(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateCdnKeyRequest( - ) - - # Make the request - operation = client.update_cdn_key(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateCdnKey_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py deleted file mode 100644 index 620c353086ea..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_async.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_update_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.UpdateLiveConfigRequest( - live_config=live_config, - ) - - # Make the request - operation = client.update_live_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py deleted file mode 100644 index 6a8ca8872608..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_live_config_sync.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateLiveConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_update_live_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - live_config = stitcher_v1.LiveConfig() - live_config.source_uri = "source_uri_value" - live_config.ad_tracking = "SERVER" - - request = stitcher_v1.UpdateLiveConfigRequest( - live_config=live_config, - ) - - # Make the request - operation = client.update_live_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateLiveConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py deleted file mode 100644 index aef61f0b0086..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_async.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateSlate_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_update_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateSlateRequest( - ) - - # Make the request - operation = client.update_slate(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateSlate_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py deleted file mode 100644 index cbb7445e4027..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_slate_sync.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateSlate -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateSlate_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_update_slate(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - request = stitcher_v1.UpdateSlateRequest( - ) - - # Make the request - operation = client.update_slate(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateSlate_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py deleted file mode 100644 index 35362d3763a2..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_async.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_async] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -async def sample_update_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceAsyncClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.UpdateVodConfigRequest( - vod_config=vod_config, - ) - - # Make the request - operation = client.update_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_async] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py b/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py deleted file mode 100644 index 62eca54d3944..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/samples/generated_samples/videostitcher_v1_generated_video_stitcher_service_update_vod_config_sync.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for UpdateVodConfig -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-video-stitcher - - -# [START videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_sync] -# This snippet has been automatically generated and should be regarded as a -# code template only. -# It will require modifications to work: -# - It may require correct/in-range values for request initialization. -# - It may require specifying regional endpoints when creating the service -# client as shown in: -# https://googleapis.dev/python/google-api-core/latest/client_options.html -from google.cloud.video import stitcher_v1 - - -def sample_update_vod_config(): - # Create a client - client = stitcher_v1.VideoStitcherServiceClient() - - # Initialize request argument(s) - vod_config = stitcher_v1.VodConfig() - vod_config.source_uri = "source_uri_value" - vod_config.ad_tag_uri = "ad_tag_uri_value" - - request = stitcher_v1.UpdateVodConfigRequest( - vod_config=vod_config, - ) - - # Make the request - operation = client.update_vod_config(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END videostitcher_v1_generated_VideoStitcherService_UpdateVodConfig_sync] diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py b/owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py deleted file mode 100644 index 0f4ecc0cfa74..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/scripts/fixup_stitcher_v1_keywords.py +++ /dev/null @@ -1,205 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class stitcherCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_cdn_key': ('parent', 'cdn_key', 'cdn_key_id', ), - 'create_live_config': ('parent', 'live_config_id', 'live_config', 'request_id', ), - 'create_live_session': ('parent', 'live_session', ), - 'create_slate': ('parent', 'slate_id', 'slate', 'request_id', ), - 'create_vod_config': ('parent', 'vod_config_id', 'vod_config', 'request_id', ), - 'create_vod_session': ('parent', 'vod_session', ), - 'delete_cdn_key': ('name', ), - 'delete_live_config': ('name', ), - 'delete_slate': ('name', ), - 'delete_vod_config': ('name', ), - 'get_cdn_key': ('name', ), - 'get_live_ad_tag_detail': ('name', ), - 'get_live_config': ('name', ), - 'get_live_session': ('name', ), - 'get_slate': ('name', ), - 'get_vod_ad_tag_detail': ('name', ), - 'get_vod_config': ('name', ), - 'get_vod_session': ('name', ), - 'get_vod_stitch_detail': ('name', ), - 'list_cdn_keys': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_live_ad_tag_details': ('parent', 'page_size', 'page_token', ), - 'list_live_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_slates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_vod_ad_tag_details': ('parent', 'page_size', 'page_token', ), - 'list_vod_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_vod_stitch_details': ('parent', 'page_size', 'page_token', ), - 'update_cdn_key': ('cdn_key', 'update_mask', ), - 'update_live_config': ('live_config', 'update_mask', ), - 'update_slate': ('slate', 'update_mask', ), - 'update_vod_config': ('vod_config', 'update_mask', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=stitcherCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the stitcher client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/setup.py b/owl-bot-staging/google-cloud-video-stitcher/v1/setup.py deleted file mode 100644 index 21e868ffe679..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/setup.py +++ /dev/null @@ -1,98 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import io -import os -import re - -import setuptools # type: ignore - -package_root = os.path.abspath(os.path.dirname(__file__)) - -name = 'google-cloud-video-stitcher' - - -description = "Google Cloud Video Stitcher API client library" - -version = None - -with open(os.path.join(package_root, 'google/cloud/video/stitcher/gapic_version.py')) as fp: - version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read()) - assert (len(version_candidates) == 1) - version = version_candidates[0] - -if version[0] == "0": - release_status = "Development Status :: 4 - Beta" -else: - release_status = "Development Status :: 5 - Production/Stable" - -dependencies = [ - "google-api-core[grpc] >= 1.34.1, <3.0.0,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", - # Exclude incompatible versions of `google-auth` - # See https://github.com/googleapis/google-cloud-python/issues/12364 - "google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0", - "proto-plus >= 1.22.3, <2.0.0", - "proto-plus >= 1.25.0, <2.0.0; python_version >= '3.13'", - "protobuf>=3.20.2,<7.0.0,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", -] -extras = { -} -url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-video-stitcher" - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, "README.rst") -with io.open(readme_filename, encoding="utf-8") as readme_file: - readme = readme_file.read() - -packages = [ - package - for package in setuptools.find_namespace_packages() - if package.startswith("google") -] - -setuptools.setup( - name=name, - version=version, - description=description, - long_description=readme, - author="Google LLC", - author_email="googleapis-packages@google.com", - license="Apache 2.0", - url=url, - classifiers=[ - release_status, - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Operating System :: OS Independent", - "Topic :: Internet", - ], - platforms="Posix; MacOS X; Windows", - packages=packages, - python_requires=">=3.7", - install_requires=dependencies, - extras_require=extras, - include_package_data=True, - zip_safe=False, -) diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.10.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.11.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.12.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt deleted file mode 100644 index c20a77817caa..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.13.txt +++ /dev/null @@ -1,11 +0,0 @@ -# We use the constraints file for the latest Python version -# (currently this file) to check that the latest -# major versions of dependencies are supported in setup.py. -# List all library dependencies and extras in this file. -# Require the latest major version be installed for each dependency. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0", -# Then this file should have google-cloud-foo>=1 -google-api-core>=2 -google-auth>=2 -proto-plus>=1 -protobuf>=6 diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt deleted file mode 100644 index a77f12bc13e4..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.7.txt +++ /dev/null @@ -1,10 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List all library dependencies and extras in this file. -# Pin the version to the lower bound. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0", -# Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.34.1 -google-auth==2.14.1 -proto-plus==1.22.3 -protobuf==3.20.2 diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.8.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt deleted file mode 100644 index ed7f9aed2559..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/testing/constraints-3.9.txt +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py deleted file mode 100644 index 191773d5572d..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py b/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py deleted file mode 100644 index 9a75ef87b6b1..000000000000 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py +++ /dev/null @@ -1,25166 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2025 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -import os -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock # pragma: NO COVER -except ImportError: # pragma: NO COVER - import mock - -import grpc -from grpc.experimental import aio -from collections.abc import Iterable, AsyncIterable -from google.protobuf import json_format -import json -import math -import pytest -from google.api_core import api_core_version -from proto.marshal.rules.dates import DurationRule, TimestampRule -from proto.marshal.rules import wrappers -from requests import Response -from requests import Request, PreparedRequest -from requests.sessions import Session -from google.protobuf import json_format - -try: - from google.auth.aio import credentials as ga_credentials_async - HAS_GOOGLE_AUTH_AIO = True -except ImportError: # pragma: NO COVER - HAS_GOOGLE_AUTH_AIO = False - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import future -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import operation -from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.video.stitcher_v1.services.video_stitcher_service import VideoStitcherServiceAsyncClient -from google.cloud.video.stitcher_v1.services.video_stitcher_service import VideoStitcherServiceClient -from google.cloud.video.stitcher_v1.services.video_stitcher_service import pagers -from google.cloud.video.stitcher_v1.services.video_stitcher_service import transports -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import companions -from google.cloud.video.stitcher_v1.types import events -from google.cloud.video.stitcher_v1.types import fetch_options -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs -from google.longrunning import operations_pb2 # type: ignore -from google.oauth2 import service_account -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -import google.auth - - - -CRED_INFO_JSON = { - "credential_source": "/path/to/file", - "credential_type": "service account credentials", - "principal": "service-account@example.com", -} -CRED_INFO_STRING = json.dumps(CRED_INFO_JSON) - - -async def mock_async_gen(data, chunk_size=1): - for i in range(0, len(data)): # pragma: NO COVER - chunk = data[i : i + chunk_size] - yield chunk.encode("utf-8") - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - -# TODO: use async auth anon credentials by default once the minimum version of google-auth is upgraded. -# See related issue: https://github.com/googleapis/gapic-generator-python/issues/2107. -def async_anonymous_credentials(): - if HAS_GOOGLE_AUTH_AIO: - return ga_credentials_async.AnonymousCredentials() - return ga_credentials.AnonymousCredentials() - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - -# If default endpoint template is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint template so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint_template(client): - return "test.{UNIVERSE_DOMAIN}" if ("localhost" in client._DEFAULT_ENDPOINT_TEMPLATE) else client._DEFAULT_ENDPOINT_TEMPLATE - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert VideoStitcherServiceClient._get_default_mtls_endpoint(None) is None - assert VideoStitcherServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert VideoStitcherServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert VideoStitcherServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert VideoStitcherServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert VideoStitcherServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - -def test__read_environment_variables(): - assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - assert VideoStitcherServiceClient._read_environment_variables() == (True, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - VideoStitcherServiceClient._read_environment_variables() - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - assert VideoStitcherServiceClient._read_environment_variables() == (False, "never", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - assert VideoStitcherServiceClient._read_environment_variables() == (False, "always", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}): - assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", None) - - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - VideoStitcherServiceClient._read_environment_variables() - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - with mock.patch.dict(os.environ, {"GOOGLE_CLOUD_UNIVERSE_DOMAIN": "foo.com"}): - assert VideoStitcherServiceClient._read_environment_variables() == (False, "auto", "foo.com") - -def test__get_client_cert_source(): - mock_provided_cert_source = mock.Mock() - mock_default_cert_source = mock.Mock() - - assert VideoStitcherServiceClient._get_client_cert_source(None, False) is None - assert VideoStitcherServiceClient._get_client_cert_source(mock_provided_cert_source, False) is None - assert VideoStitcherServiceClient._get_client_cert_source(mock_provided_cert_source, True) == mock_provided_cert_source - - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_default_cert_source): - assert VideoStitcherServiceClient._get_client_cert_source(None, True) is mock_default_cert_source - assert VideoStitcherServiceClient._get_client_cert_source(mock_provided_cert_source, "true") is mock_provided_cert_source - -@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) -@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) -def test__get_api_endpoint(): - api_override = "foo.com" - mock_client_cert_source = mock.Mock() - default_universe = VideoStitcherServiceClient._DEFAULT_UNIVERSE - default_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) - - assert VideoStitcherServiceClient._get_api_endpoint(api_override, mock_client_cert_source, default_universe, "always") == api_override - assert VideoStitcherServiceClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "auto") == VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT - assert VideoStitcherServiceClient._get_api_endpoint(None, None, default_universe, "auto") == default_endpoint - assert VideoStitcherServiceClient._get_api_endpoint(None, None, default_universe, "always") == VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT - assert VideoStitcherServiceClient._get_api_endpoint(None, mock_client_cert_source, default_universe, "always") == VideoStitcherServiceClient.DEFAULT_MTLS_ENDPOINT - assert VideoStitcherServiceClient._get_api_endpoint(None, None, mock_universe, "never") == mock_endpoint - assert VideoStitcherServiceClient._get_api_endpoint(None, None, default_universe, "never") == default_endpoint - - with pytest.raises(MutualTLSChannelError) as excinfo: - VideoStitcherServiceClient._get_api_endpoint(None, mock_client_cert_source, mock_universe, "auto") - assert str(excinfo.value) == "mTLS is not supported in any universe other than googleapis.com." - - -def test__get_universe_domain(): - client_universe_domain = "foo.com" - universe_domain_env = "bar.com" - - assert VideoStitcherServiceClient._get_universe_domain(client_universe_domain, universe_domain_env) == client_universe_domain - assert VideoStitcherServiceClient._get_universe_domain(None, universe_domain_env) == universe_domain_env - assert VideoStitcherServiceClient._get_universe_domain(None, None) == VideoStitcherServiceClient._DEFAULT_UNIVERSE - - with pytest.raises(ValueError) as excinfo: - VideoStitcherServiceClient._get_universe_domain("", None) - assert str(excinfo.value) == "Universe Domain cannot be an empty string." - -@pytest.mark.parametrize("error_code,cred_info_json,show_cred_info", [ - (401, CRED_INFO_JSON, True), - (403, CRED_INFO_JSON, True), - (404, CRED_INFO_JSON, True), - (500, CRED_INFO_JSON, False), - (401, None, False), - (403, None, False), - (404, None, False), - (500, None, False) -]) -def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info): - cred = mock.Mock(["get_cred_info"]) - cred.get_cred_info = mock.Mock(return_value=cred_info_json) - client = VideoStitcherServiceClient(credentials=cred) - client._transport._credentials = cred - - error = core_exceptions.GoogleAPICallError("message", details=["foo"]) - error.code = error_code - - client._add_cred_info_for_auth_errors(error) - if show_cred_info: - assert error.details == ["foo", CRED_INFO_STRING] - else: - assert error.details == ["foo"] - -@pytest.mark.parametrize("error_code", [401,403,404,500]) -def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code): - cred = mock.Mock([]) - assert not hasattr(cred, "get_cred_info") - client = VideoStitcherServiceClient(credentials=cred) - client._transport._credentials = cred - - error = core_exceptions.GoogleAPICallError("message", details=[]) - error.code = error_code - - client._add_cred_info_for_auth_errors(error) - assert error.details == [] - -@pytest.mark.parametrize("client_class,transport_name", [ - (VideoStitcherServiceClient, "grpc"), - (VideoStitcherServiceAsyncClient, "grpc_asyncio"), - (VideoStitcherServiceClient, "rest"), -]) -def test_video_stitcher_service_client_from_service_account_info(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'videostitcher.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://videostitcher.googleapis.com' - ) - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.VideoStitcherServiceGrpcTransport, "grpc"), - (transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.VideoStitcherServiceRestTransport, "rest"), -]) -def test_video_stitcher_service_client_service_account_always_use_jwt(transport_class, transport_name): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class,transport_name", [ - (VideoStitcherServiceClient, "grpc"), - (VideoStitcherServiceAsyncClient, "grpc_asyncio"), - (VideoStitcherServiceClient, "rest"), -]) -def test_video_stitcher_service_client_from_service_account_file(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'videostitcher.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://videostitcher.googleapis.com' - ) - - -def test_video_stitcher_service_client_get_transport_class(): - transport = VideoStitcherServiceClient.get_transport_class() - available_transports = [ - transports.VideoStitcherServiceGrpcTransport, - transports.VideoStitcherServiceRestTransport, - ] - assert transport in available_transports - - transport = VideoStitcherServiceClient.get_transport_class("grpc") - assert transport == transports.VideoStitcherServiceGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc"), - (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio"), - (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest"), -]) -@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) -@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) -def test_video_stitcher_service_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(VideoStitcherServiceClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(VideoStitcherServiceClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - client = client_class(transport=transport_name) - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - client = client_class(transport=transport_name) - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - # Check the case api_endpoint is provided - options = client_options.ClientOptions(api_audience="https://language.googleapis.com") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience="https://language.googleapis.com" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", "true"), - (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", "false"), - (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", "false"), - (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest", "true"), - (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest", "false"), -]) -@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) -@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_video_stitcher_service_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE) - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - VideoStitcherServiceClient, VideoStitcherServiceAsyncClient -]) -@mock.patch.object(VideoStitcherServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VideoStitcherServiceClient)) -@mock.patch.object(VideoStitcherServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(VideoStitcherServiceAsyncClient)) -def test_video_stitcher_service_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError) as excinfo: - client_class.get_mtls_endpoint_and_cert_source() - - assert str(excinfo.value) == "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - -@pytest.mark.parametrize("client_class", [ - VideoStitcherServiceClient, VideoStitcherServiceAsyncClient -]) -@mock.patch.object(VideoStitcherServiceClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceClient)) -@mock.patch.object(VideoStitcherServiceAsyncClient, "_DEFAULT_ENDPOINT_TEMPLATE", modify_default_endpoint_template(VideoStitcherServiceAsyncClient)) -def test_video_stitcher_service_client_client_api_endpoint(client_class): - mock_client_cert_source = client_cert_source_callback - api_override = "foo.com" - default_universe = VideoStitcherServiceClient._DEFAULT_UNIVERSE - default_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=default_universe) - mock_universe = "bar.com" - mock_endpoint = VideoStitcherServiceClient._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=mock_universe) - - # If ClientOptions.api_endpoint is set and GOOGLE_API_USE_CLIENT_CERTIFICATE="true", - # use ClientOptions.api_endpoint as the api endpoint regardless. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel"): - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=api_override) - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == api_override - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == default_endpoint - - # If ClientOptions.api_endpoint is not set and GOOGLE_API_USE_MTLS_ENDPOINT="always", - # use the DEFAULT_MTLS_ENDPOINT as the api endpoint. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - client = client_class(credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - - # If ClientOptions.api_endpoint is not set, GOOGLE_API_USE_MTLS_ENDPOINT="auto" (default), - # GOOGLE_API_USE_CLIENT_CERTIFICATE="false" (default), default cert source doesn't exist, - # and ClientOptions.universe_domain="bar.com", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with universe domain as the api endpoint. - options = client_options.ClientOptions() - universe_exists = hasattr(options, "universe_domain") - if universe_exists: - options = client_options.ClientOptions(universe_domain=mock_universe) - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - else: - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == (mock_endpoint if universe_exists else default_endpoint) - assert client.universe_domain == (mock_universe if universe_exists else default_universe) - - # If ClientOptions does not have a universe domain attribute and GOOGLE_API_USE_MTLS_ENDPOINT="never", - # use the _DEFAULT_ENDPOINT_TEMPLATE populated with GDU as the api endpoint. - options = client_options.ClientOptions() - if hasattr(options, "universe_domain"): - delattr(options, "universe_domain") - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - client = client_class(client_options=options, credentials=ga_credentials.AnonymousCredentials()) - assert client.api_endpoint == default_endpoint - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc"), - (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio"), - (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest"), -]) -def test_video_stitcher_service_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", grpc_helpers), - (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), - (VideoStitcherServiceClient, transports.VideoStitcherServiceRestTransport, "rest", None), -]) -def test_video_stitcher_service_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -def test_video_stitcher_service_client_client_options_from_dict(): - with mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = VideoStitcherServiceClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport, "grpc", grpc_helpers), - (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_video_stitcher_service_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "videostitcher.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=None, - default_host="videostitcher.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateCdnKeyRequest, - dict, -]) -def test_create_cdn_key(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_cdn_key_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.CreateCdnKeyRequest( - parent='parent_value', - cdn_key_id='cdn_key_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_cdn_key(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.CreateCdnKeyRequest( - parent='parent_value', - cdn_key_id='cdn_key_id_value', - ) - -def test_create_cdn_key_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_cdn_key] = mock_rpc - request = {} - client.create_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_cdn_key in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_cdn_key] = mock_rpc - - request = {} - await client.create_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.create_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateCdnKeyRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.create_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_cdn_key_async_from_dict(): - await test_create_cdn_key_async(request_type=dict) - -def test_create_cdn_key_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateCdnKeyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_cdn_key_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateCdnKeyRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_cdn_key_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_cdn_key( - parent='parent_value', - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - cdn_key_id='cdn_key_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].cdn_key - mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) - assert arg == mock_val - arg = args[0].cdn_key_id - mock_val = 'cdn_key_id_value' - assert arg == mock_val - - -def test_create_cdn_key_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_cdn_key( - video_stitcher_service.CreateCdnKeyRequest(), - parent='parent_value', - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - cdn_key_id='cdn_key_id_value', - ) - -@pytest.mark.asyncio -async def test_create_cdn_key_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_cdn_key( - parent='parent_value', - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - cdn_key_id='cdn_key_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].cdn_key - mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) - assert arg == mock_val - arg = args[0].cdn_key_id - mock_val = 'cdn_key_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_cdn_key_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_cdn_key( - video_stitcher_service.CreateCdnKeyRequest(), - parent='parent_value', - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - cdn_key_id='cdn_key_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListCdnKeysRequest, - dict, -]) -def test_list_cdn_keys(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListCdnKeysResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_cdn_keys(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListCdnKeysRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCdnKeysPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_cdn_keys_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.ListCdnKeysRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_cdn_keys(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.ListCdnKeysRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_cdn_keys_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_cdn_keys in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_cdn_keys] = mock_rpc - request = {} - client.list_cdn_keys(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_cdn_keys(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_cdn_keys_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_cdn_keys in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_cdn_keys] = mock_rpc - - request = {} - await client.list_cdn_keys(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_cdn_keys(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_cdn_keys_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListCdnKeysRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_cdn_keys(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListCdnKeysRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCdnKeysAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_cdn_keys_async_from_dict(): - await test_list_cdn_keys_async(request_type=dict) - -def test_list_cdn_keys_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListCdnKeysRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - call.return_value = video_stitcher_service.ListCdnKeysResponse() - client.list_cdn_keys(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_cdn_keys_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListCdnKeysRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse()) - await client.list_cdn_keys(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_cdn_keys_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListCdnKeysResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_cdn_keys( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_cdn_keys_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_cdn_keys( - video_stitcher_service.ListCdnKeysRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_cdn_keys_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListCdnKeysResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_cdn_keys( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_cdn_keys_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_cdn_keys( - video_stitcher_service.ListCdnKeysRequest(), - parent='parent_value', - ) - - -def test_list_cdn_keys_pager(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[], - next_page_token='def', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_cdn_keys(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, cdn_keys.CdnKey) - for i in results) -def test_list_cdn_keys_pages(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[], - next_page_token='def', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - ), - RuntimeError, - ) - pages = list(client.list_cdn_keys(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_cdn_keys_async_pager(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[], - next_page_token='def', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_cdn_keys(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, cdn_keys.CdnKey) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_cdn_keys_async_pages(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[], - next_page_token='def', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_cdn_keys(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetCdnKeyRequest, - dict, -]) -def test_get_cdn_key(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = cdn_keys.CdnKey( - name='name_value', - hostname='hostname_value', - ) - response = client.get_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, cdn_keys.CdnKey) - assert response.name == 'name_value' - assert response.hostname == 'hostname_value' - - -def test_get_cdn_key_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetCdnKeyRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_cdn_key(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetCdnKeyRequest( - name='name_value', - ) - -def test_get_cdn_key_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_cdn_key] = mock_rpc - request = {} - client.get_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_cdn_key in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_cdn_key] = mock_rpc - - request = {} - await client.get_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetCdnKeyRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey( - name='name_value', - hostname='hostname_value', - )) - response = await client.get_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, cdn_keys.CdnKey) - assert response.name == 'name_value' - assert response.hostname == 'hostname_value' - - -@pytest.mark.asyncio -async def test_get_cdn_key_async_from_dict(): - await test_get_cdn_key_async(request_type=dict) - -def test_get_cdn_key_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetCdnKeyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - call.return_value = cdn_keys.CdnKey() - client.get_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_cdn_key_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetCdnKeyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey()) - await client.get_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_cdn_key_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = cdn_keys.CdnKey() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_cdn_key( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_cdn_key_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_cdn_key( - video_stitcher_service.GetCdnKeyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_cdn_key_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = cdn_keys.CdnKey() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_cdn_key( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_cdn_key_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_cdn_key( - video_stitcher_service.GetCdnKeyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteCdnKeyRequest, - dict, -]) -def test_delete_cdn_key(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_cdn_key_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.DeleteCdnKeyRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_cdn_key(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.DeleteCdnKeyRequest( - name='name_value', - ) - -def test_delete_cdn_key_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_cdn_key] = mock_rpc - request = {} - client.delete_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_cdn_key in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_cdn_key] = mock_rpc - - request = {} - await client.delete_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteCdnKeyRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.delete_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_cdn_key_async_from_dict(): - await test_delete_cdn_key_async(request_type=dict) - -def test_delete_cdn_key_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteCdnKeyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_cdn_key_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteCdnKeyRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_cdn_key_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_cdn_key( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_cdn_key_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_cdn_key( - video_stitcher_service.DeleteCdnKeyRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_cdn_key_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_cdn_key( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_cdn_key_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_cdn_key( - video_stitcher_service.DeleteCdnKeyRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateCdnKeyRequest, - dict, -]) -def test_update_cdn_key(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_cdn_key_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.UpdateCdnKeyRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_cdn_key(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.UpdateCdnKeyRequest( - ) - -def test_update_cdn_key_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_cdn_key] = mock_rpc - request = {} - client.update_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_cdn_key_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_cdn_key in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_cdn_key] = mock_rpc - - request = {} - await client.update_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.update_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_cdn_key_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateCdnKeyRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.update_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateCdnKeyRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_cdn_key_async_from_dict(): - await test_update_cdn_key_async(request_type=dict) - -def test_update_cdn_key_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateCdnKeyRequest() - - request.cdn_key.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'cdn_key.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_cdn_key_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateCdnKeyRequest() - - request.cdn_key.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'cdn_key.name=name_value', - ) in kw['metadata'] - - -def test_update_cdn_key_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_cdn_key( - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].cdn_key - mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_cdn_key_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_cdn_key( - video_stitcher_service.UpdateCdnKeyRequest(), - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_cdn_key_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_cdn_key( - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].cdn_key - mock_val = cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')) - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_cdn_key_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_cdn_key( - video_stitcher_service.UpdateCdnKeyRequest(), - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateVodSessionRequest, - dict, -]) -def test_create_vod_session(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - ) - response = client.create_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateVodSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.VodSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.asset_id == 'asset_id_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.vod_config == 'vod_config_value' - - -def test_create_vod_session_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.CreateVodSessionRequest( - parent='parent_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_vod_session(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.CreateVodSessionRequest( - parent='parent_value', - ) - -def test_create_vod_session_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_vod_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_vod_session] = mock_rpc - request = {} - client.create_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_vod_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_vod_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_vod_session in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_vod_session] = mock_rpc - - request = {} - await client.create_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.create_vod_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_vod_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateVodSessionRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - )) - response = await client.create_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateVodSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.VodSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.asset_id == 'asset_id_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.vod_config == 'vod_config_value' - - -@pytest.mark.asyncio -async def test_create_vod_session_async_from_dict(): - await test_create_vod_session_async(request_type=dict) - -def test_create_vod_session_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateVodSessionRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - call.return_value = sessions.VodSession() - client.create_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_vod_session_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateVodSessionRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) - await client.create_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_vod_session_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.VodSession() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_vod_session( - parent='parent_value', - vod_session=sessions.VodSession(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].vod_session - mock_val = sessions.VodSession(name='name_value') - assert arg == mock_val - - -def test_create_vod_session_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_vod_session( - video_stitcher_service.CreateVodSessionRequest(), - parent='parent_value', - vod_session=sessions.VodSession(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_vod_session_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.VodSession() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_vod_session( - parent='parent_value', - vod_session=sessions.VodSession(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].vod_session - mock_val = sessions.VodSession(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_vod_session_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_vod_session( - video_stitcher_service.CreateVodSessionRequest(), - parent='parent_value', - vod_session=sessions.VodSession(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodSessionRequest, - dict, -]) -def test_get_vod_session(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - ) - response = client.get_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.VodSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.asset_id == 'asset_id_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.vod_config == 'vod_config_value' - - -def test_get_vod_session_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetVodSessionRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_vod_session(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetVodSessionRequest( - name='name_value', - ) - -def test_get_vod_session_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_session] = mock_rpc - request = {} - client.get_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_vod_session in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_vod_session] = mock_rpc - - request = {} - await client.get_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_vod_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodSessionRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - )) - response = await client.get_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.VodSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.asset_id == 'asset_id_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.vod_config == 'vod_config_value' - - -@pytest.mark.asyncio -async def test_get_vod_session_async_from_dict(): - await test_get_vod_session_async(request_type=dict) - -def test_get_vod_session_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodSessionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - call.return_value = sessions.VodSession() - client.get_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_vod_session_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodSessionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) - await client.get_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_vod_session_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.VodSession() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_vod_session( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_vod_session_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_session( - video_stitcher_service.GetVodSessionRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_vod_session_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.VodSession() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_vod_session( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_vod_session_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_vod_session( - video_stitcher_service.GetVodSessionRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListVodStitchDetailsRequest, - dict, -]) -def test_list_vod_stitch_details(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodStitchDetailsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_vod_stitch_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListVodStitchDetailsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodStitchDetailsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_vod_stitch_details_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.ListVodStitchDetailsRequest( - parent='parent_value', - page_token='page_token_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_vod_stitch_details(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.ListVodStitchDetailsRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_vod_stitch_details_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_vod_stitch_details in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_vod_stitch_details] = mock_rpc - request = {} - client.list_vod_stitch_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_vod_stitch_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_vod_stitch_details in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_vod_stitch_details] = mock_rpc - - request = {} - await client.list_vod_stitch_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_vod_stitch_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListVodStitchDetailsRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_vod_stitch_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListVodStitchDetailsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodStitchDetailsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_async_from_dict(): - await test_list_vod_stitch_details_async(request_type=dict) - -def test_list_vod_stitch_details_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListVodStitchDetailsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() - client.list_vod_stitch_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListVodStitchDetailsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse()) - await client.list_vod_stitch_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_vod_stitch_details_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_vod_stitch_details( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_vod_stitch_details_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_vod_stitch_details( - video_stitcher_service.ListVodStitchDetailsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_vod_stitch_details( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_vod_stitch_details( - video_stitcher_service.ListVodStitchDetailsRequest(), - parent='parent_value', - ) - - -def test_list_vod_stitch_details_pager(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_vod_stitch_details(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, stitch_details.VodStitchDetail) - for i in results) -def test_list_vod_stitch_details_pages(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - ), - RuntimeError, - ) - pages = list(client.list_vod_stitch_details(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_async_pager(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_vod_stitch_details(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, stitch_details.VodStitchDetail) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_vod_stitch_details_async_pages(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_vod_stitch_details(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodStitchDetailRequest, - dict, -]) -def test_get_vod_stitch_detail(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = stitch_details.VodStitchDetail( - name='name_value', - ) - response = client.get_vod_stitch_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodStitchDetailRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, stitch_details.VodStitchDetail) - assert response.name == 'name_value' - - -def test_get_vod_stitch_detail_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetVodStitchDetailRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_vod_stitch_detail(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetVodStitchDetailRequest( - name='name_value', - ) - -def test_get_vod_stitch_detail_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_stitch_detail in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_stitch_detail] = mock_rpc - request = {} - client.get_vod_stitch_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_stitch_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_vod_stitch_detail in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_vod_stitch_detail] = mock_rpc - - request = {} - await client.get_vod_stitch_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_vod_stitch_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodStitchDetailRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail( - name='name_value', - )) - response = await client.get_vod_stitch_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodStitchDetailRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, stitch_details.VodStitchDetail) - assert response.name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_async_from_dict(): - await test_get_vod_stitch_detail_async(request_type=dict) - -def test_get_vod_stitch_detail_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodStitchDetailRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - call.return_value = stitch_details.VodStitchDetail() - client.get_vod_stitch_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodStitchDetailRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail()) - await client.get_vod_stitch_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_vod_stitch_detail_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = stitch_details.VodStitchDetail() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_vod_stitch_detail( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_vod_stitch_detail_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_stitch_detail( - video_stitcher_service.GetVodStitchDetailRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = stitch_details.VodStitchDetail() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_vod_stitch_detail( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_vod_stitch_detail( - video_stitcher_service.GetVodStitchDetailRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListVodAdTagDetailsRequest, - dict, -]) -def test_list_vod_ad_tag_details(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_vod_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListVodAdTagDetailsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodAdTagDetailsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_vod_ad_tag_details_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.ListVodAdTagDetailsRequest( - parent='parent_value', - page_token='page_token_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_vod_ad_tag_details(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.ListVodAdTagDetailsRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_vod_ad_tag_details_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_vod_ad_tag_details in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_vod_ad_tag_details] = mock_rpc - request = {} - client.list_vod_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_vod_ad_tag_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_vod_ad_tag_details in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_vod_ad_tag_details] = mock_rpc - - request = {} - await client.list_vod_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_vod_ad_tag_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListVodAdTagDetailsRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_vod_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListVodAdTagDetailsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodAdTagDetailsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_async_from_dict(): - await test_list_vod_ad_tag_details_async(request_type=dict) - -def test_list_vod_ad_tag_details_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListVodAdTagDetailsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - client.list_vod_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListVodAdTagDetailsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse()) - await client.list_vod_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_vod_ad_tag_details_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_vod_ad_tag_details( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_vod_ad_tag_details_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_vod_ad_tag_details( - video_stitcher_service.ListVodAdTagDetailsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_vod_ad_tag_details( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_vod_ad_tag_details( - video_stitcher_service.ListVodAdTagDetailsRequest(), - parent='parent_value', - ) - - -def test_list_vod_ad_tag_details_pager(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_vod_ad_tag_details(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, ad_tag_details.VodAdTagDetail) - for i in results) -def test_list_vod_ad_tag_details_pages(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - ), - RuntimeError, - ) - pages = list(client.list_vod_ad_tag_details(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_async_pager(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_vod_ad_tag_details(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, ad_tag_details.VodAdTagDetail) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_async_pages(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_vod_ad_tag_details(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodAdTagDetailRequest, - dict, -]) -def test_get_vod_ad_tag_detail(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = ad_tag_details.VodAdTagDetail( - name='name_value', - ) - response = client.get_vod_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodAdTagDetailRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, ad_tag_details.VodAdTagDetail) - assert response.name == 'name_value' - - -def test_get_vod_ad_tag_detail_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetVodAdTagDetailRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_vod_ad_tag_detail(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetVodAdTagDetailRequest( - name='name_value', - ) - -def test_get_vod_ad_tag_detail_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_ad_tag_detail in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_ad_tag_detail] = mock_rpc - request = {} - client.get_vod_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_ad_tag_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_vod_ad_tag_detail in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_vod_ad_tag_detail] = mock_rpc - - request = {} - await client.get_vod_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_vod_ad_tag_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodAdTagDetailRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail( - name='name_value', - )) - response = await client.get_vod_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodAdTagDetailRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, ad_tag_details.VodAdTagDetail) - assert response.name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_async_from_dict(): - await test_get_vod_ad_tag_detail_async(request_type=dict) - -def test_get_vod_ad_tag_detail_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodAdTagDetailRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - call.return_value = ad_tag_details.VodAdTagDetail() - client.get_vod_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodAdTagDetailRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail()) - await client.get_vod_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_vod_ad_tag_detail_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = ad_tag_details.VodAdTagDetail() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_vod_ad_tag_detail( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_vod_ad_tag_detail_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_ad_tag_detail( - video_stitcher_service.GetVodAdTagDetailRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = ad_tag_details.VodAdTagDetail() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_vod_ad_tag_detail( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_vod_ad_tag_detail( - video_stitcher_service.GetVodAdTagDetailRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListLiveAdTagDetailsRequest, - dict, -]) -def test_list_live_ad_tag_details(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse( - next_page_token='next_page_token_value', - ) - response = client.list_live_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListLiveAdTagDetailsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListLiveAdTagDetailsPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_live_ad_tag_details_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.ListLiveAdTagDetailsRequest( - parent='parent_value', - page_token='page_token_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_live_ad_tag_details(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.ListLiveAdTagDetailsRequest( - parent='parent_value', - page_token='page_token_value', - ) - -def test_list_live_ad_tag_details_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_live_ad_tag_details in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_live_ad_tag_details] = mock_rpc - request = {} - client.list_live_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_live_ad_tag_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_live_ad_tag_details in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_live_ad_tag_details] = mock_rpc - - request = {} - await client.list_live_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_live_ad_tag_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListLiveAdTagDetailsRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_live_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListLiveAdTagDetailsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListLiveAdTagDetailsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_async_from_dict(): - await test_list_live_ad_tag_details_async(request_type=dict) - -def test_list_live_ad_tag_details_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListLiveAdTagDetailsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - client.list_live_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListLiveAdTagDetailsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse()) - await client.list_live_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_live_ad_tag_details_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_live_ad_tag_details( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_live_ad_tag_details_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_live_ad_tag_details( - video_stitcher_service.ListLiveAdTagDetailsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_live_ad_tag_details( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_live_ad_tag_details( - video_stitcher_service.ListLiveAdTagDetailsRequest(), - parent='parent_value', - ) - - -def test_list_live_ad_tag_details_pager(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_live_ad_tag_details(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, ad_tag_details.LiveAdTagDetail) - for i in results) -def test_list_live_ad_tag_details_pages(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - ), - RuntimeError, - ) - pages = list(client.list_live_ad_tag_details(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_async_pager(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_live_ad_tag_details(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, ad_tag_details.LiveAdTagDetail) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_async_pages(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_live_ad_tag_details(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetLiveAdTagDetailRequest, - dict, -]) -def test_get_live_ad_tag_detail(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = ad_tag_details.LiveAdTagDetail( - name='name_value', - ) - response = client.get_live_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetLiveAdTagDetailRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, ad_tag_details.LiveAdTagDetail) - assert response.name == 'name_value' - - -def test_get_live_ad_tag_detail_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetLiveAdTagDetailRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_live_ad_tag_detail(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetLiveAdTagDetailRequest( - name='name_value', - ) - -def test_get_live_ad_tag_detail_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_live_ad_tag_detail in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_live_ad_tag_detail] = mock_rpc - request = {} - client.get_live_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_live_ad_tag_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_live_ad_tag_detail in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_live_ad_tag_detail] = mock_rpc - - request = {} - await client.get_live_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_live_ad_tag_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetLiveAdTagDetailRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail( - name='name_value', - )) - response = await client.get_live_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetLiveAdTagDetailRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, ad_tag_details.LiveAdTagDetail) - assert response.name == 'name_value' - - -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_async_from_dict(): - await test_get_live_ad_tag_detail_async(request_type=dict) - -def test_get_live_ad_tag_detail_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetLiveAdTagDetailRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - call.return_value = ad_tag_details.LiveAdTagDetail() - client.get_live_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetLiveAdTagDetailRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail()) - await client.get_live_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_live_ad_tag_detail_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = ad_tag_details.LiveAdTagDetail() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_live_ad_tag_detail( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_live_ad_tag_detail_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_live_ad_tag_detail( - video_stitcher_service.GetLiveAdTagDetailRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = ad_tag_details.LiveAdTagDetail() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_live_ad_tag_detail( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_live_ad_tag_detail( - video_stitcher_service.GetLiveAdTagDetailRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateSlateRequest, - dict, -]) -def test_create_slate(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_slate_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.CreateSlateRequest( - parent='parent_value', - slate_id='slate_id_value', - request_id='request_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_slate(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.CreateSlateRequest( - parent='parent_value', - slate_id='slate_id_value', - request_id='request_id_value', - ) - -def test_create_slate_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_slate] = mock_rpc - request = {} - client.create_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_slate in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_slate] = mock_rpc - - request = {} - await client.create_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.create_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateSlateRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.create_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_slate_async_from_dict(): - await test_create_slate_async(request_type=dict) - -def test_create_slate_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateSlateRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_slate_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateSlateRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_slate_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_slate( - parent='parent_value', - slate=slates.Slate(name='name_value'), - slate_id='slate_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].slate - mock_val = slates.Slate(name='name_value') - assert arg == mock_val - arg = args[0].slate_id - mock_val = 'slate_id_value' - assert arg == mock_val - - -def test_create_slate_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_slate( - video_stitcher_service.CreateSlateRequest(), - parent='parent_value', - slate=slates.Slate(name='name_value'), - slate_id='slate_id_value', - ) - -@pytest.mark.asyncio -async def test_create_slate_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_slate( - parent='parent_value', - slate=slates.Slate(name='name_value'), - slate_id='slate_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].slate - mock_val = slates.Slate(name='name_value') - assert arg == mock_val - arg = args[0].slate_id - mock_val = 'slate_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_slate_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_slate( - video_stitcher_service.CreateSlateRequest(), - parent='parent_value', - slate=slates.Slate(name='name_value'), - slate_id='slate_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListSlatesRequest, - dict, -]) -def test_list_slates(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListSlatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_slates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListSlatesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSlatesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_slates_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.ListSlatesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_slates(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.ListSlatesRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_slates_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_slates in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_slates] = mock_rpc - request = {} - client.list_slates(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_slates(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_slates_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_slates in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_slates] = mock_rpc - - request = {} - await client.list_slates(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_slates(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_slates_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListSlatesRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_slates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListSlatesRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSlatesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_slates_async_from_dict(): - await test_list_slates_async(request_type=dict) - -def test_list_slates_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListSlatesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - call.return_value = video_stitcher_service.ListSlatesResponse() - client.list_slates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_slates_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListSlatesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse()) - await client.list_slates(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_slates_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListSlatesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_slates( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_slates_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_slates( - video_stitcher_service.ListSlatesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_slates_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListSlatesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_slates( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_slates_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_slates( - video_stitcher_service.ListSlatesRequest(), - parent='parent_value', - ) - - -def test_list_slates_pager(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - slates.Slate(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListSlatesResponse( - slates=[], - next_page_token='def', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_slates(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, slates.Slate) - for i in results) -def test_list_slates_pages(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - slates.Slate(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListSlatesResponse( - slates=[], - next_page_token='def', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - ], - ), - RuntimeError, - ) - pages = list(client.list_slates(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_slates_async_pager(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - slates.Slate(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListSlatesResponse( - slates=[], - next_page_token='def', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_slates(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, slates.Slate) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_slates_async_pages(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - slates.Slate(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListSlatesResponse( - slates=[], - next_page_token='def', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_slates(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetSlateRequest, - dict, -]) -def test_get_slate(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = slates.Slate( - name='name_value', - uri='uri_value', - ) - response = client.get_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, slates.Slate) - assert response.name == 'name_value' - assert response.uri == 'uri_value' - - -def test_get_slate_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetSlateRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_slate(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetSlateRequest( - name='name_value', - ) - -def test_get_slate_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_slate] = mock_rpc - request = {} - client.get_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_slate in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_slate] = mock_rpc - - request = {} - await client.get_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetSlateRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate( - name='name_value', - uri='uri_value', - )) - response = await client.get_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, slates.Slate) - assert response.name == 'name_value' - assert response.uri == 'uri_value' - - -@pytest.mark.asyncio -async def test_get_slate_async_from_dict(): - await test_get_slate_async(request_type=dict) - -def test_get_slate_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetSlateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - call.return_value = slates.Slate() - client.get_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_slate_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetSlateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate()) - await client.get_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_slate_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = slates.Slate() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_slate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_slate_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_slate( - video_stitcher_service.GetSlateRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_slate_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = slates.Slate() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_slate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_slate_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_slate( - video_stitcher_service.GetSlateRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateSlateRequest, - dict, -]) -def test_update_slate(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_slate_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.UpdateSlateRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_slate(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.UpdateSlateRequest( - ) - -def test_update_slate_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_slate] = mock_rpc - request = {} - client.update_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_slate in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_slate] = mock_rpc - - request = {} - await client.update_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.update_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateSlateRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.update_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_slate_async_from_dict(): - await test_update_slate_async(request_type=dict) - -def test_update_slate_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateSlateRequest() - - request.slate.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'slate.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_slate_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateSlateRequest() - - request.slate.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'slate.name=name_value', - ) in kw['metadata'] - - -def test_update_slate_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_slate( - slate=slates.Slate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].slate - mock_val = slates.Slate(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_slate_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_slate( - video_stitcher_service.UpdateSlateRequest(), - slate=slates.Slate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_slate_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_slate( - slate=slates.Slate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].slate - mock_val = slates.Slate(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_slate_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_slate( - video_stitcher_service.UpdateSlateRequest(), - slate=slates.Slate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteSlateRequest, - dict, -]) -def test_delete_slate(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_slate_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.DeleteSlateRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_slate(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.DeleteSlateRequest( - name='name_value', - ) - -def test_delete_slate_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_slate] = mock_rpc - request = {} - client.delete_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_slate_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_slate in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_slate] = mock_rpc - - request = {} - await client.delete_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_slate_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteSlateRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.delete_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteSlateRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_slate_async_from_dict(): - await test_delete_slate_async(request_type=dict) - -def test_delete_slate_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteSlateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_slate_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteSlateRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_slate_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_slate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_slate_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_slate( - video_stitcher_service.DeleteSlateRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_slate_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_slate( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_slate_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_slate( - video_stitcher_service.DeleteSlateRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateLiveSessionRequest, - dict, -]) -def test_create_live_session(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - ) - response = client.create_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateLiveSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.LiveSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.live_config == 'live_config_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - - -def test_create_live_session_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.CreateLiveSessionRequest( - parent='parent_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_live_session(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.CreateLiveSessionRequest( - parent='parent_value', - ) - -def test_create_live_session_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_live_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_live_session] = mock_rpc - request = {} - client.create_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_live_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_live_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_live_session in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_live_session] = mock_rpc - - request = {} - await client.create_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.create_live_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_live_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateLiveSessionRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - )) - response = await client.create_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateLiveSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.LiveSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.live_config == 'live_config_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - - -@pytest.mark.asyncio -async def test_create_live_session_async_from_dict(): - await test_create_live_session_async(request_type=dict) - -def test_create_live_session_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateLiveSessionRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - call.return_value = sessions.LiveSession() - client.create_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_live_session_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateLiveSessionRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) - await client.create_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_live_session_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.LiveSession() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_live_session( - parent='parent_value', - live_session=sessions.LiveSession(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].live_session - mock_val = sessions.LiveSession(name='name_value') - assert arg == mock_val - - -def test_create_live_session_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_live_session( - video_stitcher_service.CreateLiveSessionRequest(), - parent='parent_value', - live_session=sessions.LiveSession(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_live_session_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.LiveSession() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_live_session( - parent='parent_value', - live_session=sessions.LiveSession(name='name_value'), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].live_session - mock_val = sessions.LiveSession(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_live_session_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_live_session( - video_stitcher_service.CreateLiveSessionRequest(), - parent='parent_value', - live_session=sessions.LiveSession(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetLiveSessionRequest, - dict, -]) -def test_get_live_session(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - ) - response = client.get_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetLiveSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.LiveSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.live_config == 'live_config_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - - -def test_get_live_session_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetLiveSessionRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_live_session(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetLiveSessionRequest( - name='name_value', - ) - -def test_get_live_session_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_live_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_live_session] = mock_rpc - request = {} - client.get_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_live_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_live_session_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_live_session in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_live_session] = mock_rpc - - request = {} - await client.get_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_live_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_live_session_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetLiveSessionRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - )) - response = await client.get_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetLiveSessionRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.LiveSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.live_config == 'live_config_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - - -@pytest.mark.asyncio -async def test_get_live_session_async_from_dict(): - await test_get_live_session_async(request_type=dict) - -def test_get_live_session_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetLiveSessionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - call.return_value = sessions.LiveSession() - client.get_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_live_session_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetLiveSessionRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) - await client.get_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_live_session_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.LiveSession() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_live_session( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_live_session_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_live_session( - video_stitcher_service.GetLiveSessionRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_live_session_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = sessions.LiveSession() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_live_session( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_live_session_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_live_session( - video_stitcher_service.GetLiveSessionRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateLiveConfigRequest, - dict, -]) -def test_create_live_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_live_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.CreateLiveConfigRequest( - parent='parent_value', - live_config_id='live_config_id_value', - request_id='request_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_live_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.CreateLiveConfigRequest( - parent='parent_value', - live_config_id='live_config_id_value', - request_id='request_id_value', - ) - -def test_create_live_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_live_config] = mock_rpc - request = {} - client.create_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_live_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_live_config] = mock_rpc - - request = {} - await client.create_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.create_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateLiveConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.create_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_live_config_async_from_dict(): - await test_create_live_config_async(request_type=dict) - -def test_create_live_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateLiveConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_live_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateLiveConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_live_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_live_config( - parent='parent_value', - live_config=live_configs.LiveConfig(name='name_value'), - live_config_id='live_config_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].live_config - mock_val = live_configs.LiveConfig(name='name_value') - assert arg == mock_val - arg = args[0].live_config_id - mock_val = 'live_config_id_value' - assert arg == mock_val - - -def test_create_live_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_live_config( - video_stitcher_service.CreateLiveConfigRequest(), - parent='parent_value', - live_config=live_configs.LiveConfig(name='name_value'), - live_config_id='live_config_id_value', - ) - -@pytest.mark.asyncio -async def test_create_live_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_live_config( - parent='parent_value', - live_config=live_configs.LiveConfig(name='name_value'), - live_config_id='live_config_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].live_config - mock_val = live_configs.LiveConfig(name='name_value') - assert arg == mock_val - arg = args[0].live_config_id - mock_val = 'live_config_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_live_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_live_config( - video_stitcher_service.CreateLiveConfigRequest(), - parent='parent_value', - live_config=live_configs.LiveConfig(name='name_value'), - live_config_id='live_config_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListLiveConfigsRequest, - dict, -]) -def test_list_live_configs(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListLiveConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_live_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListLiveConfigsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListLiveConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_live_configs_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.ListLiveConfigsRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_live_configs(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.ListLiveConfigsRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_live_configs_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_live_configs in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_live_configs] = mock_rpc - request = {} - client.list_live_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_live_configs(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_live_configs_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_live_configs in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_live_configs] = mock_rpc - - request = {} - await client.list_live_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_live_configs(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_live_configs_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListLiveConfigsRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_live_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListLiveConfigsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListLiveConfigsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_live_configs_async_from_dict(): - await test_list_live_configs_async(request_type=dict) - -def test_list_live_configs_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListLiveConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - call.return_value = video_stitcher_service.ListLiveConfigsResponse() - client.list_live_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_live_configs_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListLiveConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse()) - await client.list_live_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_live_configs_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListLiveConfigsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_live_configs( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_live_configs_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_live_configs( - video_stitcher_service.ListLiveConfigsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_live_configs_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListLiveConfigsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_live_configs( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_live_configs_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_live_configs( - video_stitcher_service.ListLiveConfigsRequest(), - parent='parent_value', - ) - - -def test_list_live_configs_pager(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_live_configs(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, live_configs.LiveConfig) - for i in results) -def test_list_live_configs_pages(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - ), - RuntimeError, - ) - pages = list(client.list_live_configs(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_live_configs_async_pager(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_live_configs(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, live_configs.LiveConfig) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_live_configs_async_pages(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_live_configs(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetLiveConfigRequest, - dict, -]) -def test_get_live_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = live_configs.LiveConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=live_configs.LiveConfig.State.CREATING, - ad_tracking=live_configs.AdTracking.CLIENT, - default_slate='default_slate_value', - stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, - ) - response = client.get_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, live_configs.LiveConfig) - assert response.name == 'name_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.state == live_configs.LiveConfig.State.CREATING - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.default_slate == 'default_slate_value' - assert response.stitching_policy == live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT - - -def test_get_live_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetLiveConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_live_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetLiveConfigRequest( - name='name_value', - ) - -def test_get_live_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_live_config] = mock_rpc - request = {} - client.get_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_live_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_live_config] = mock_rpc - - request = {} - await client.get_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetLiveConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=live_configs.LiveConfig.State.CREATING, - ad_tracking=live_configs.AdTracking.CLIENT, - default_slate='default_slate_value', - stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, - )) - response = await client.get_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, live_configs.LiveConfig) - assert response.name == 'name_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.state == live_configs.LiveConfig.State.CREATING - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.default_slate == 'default_slate_value' - assert response.stitching_policy == live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT - - -@pytest.mark.asyncio -async def test_get_live_config_async_from_dict(): - await test_get_live_config_async(request_type=dict) - -def test_get_live_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetLiveConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - call.return_value = live_configs.LiveConfig() - client.get_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_live_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetLiveConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig()) - await client.get_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_live_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = live_configs.LiveConfig() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_live_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_live_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_live_config( - video_stitcher_service.GetLiveConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_live_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = live_configs.LiveConfig() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_live_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_live_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_live_config( - video_stitcher_service.GetLiveConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteLiveConfigRequest, - dict, -]) -def test_delete_live_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_live_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.DeleteLiveConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_live_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.DeleteLiveConfigRequest( - name='name_value', - ) - -def test_delete_live_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_live_config] = mock_rpc - request = {} - client.delete_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_live_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_live_config] = mock_rpc - - request = {} - await client.delete_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteLiveConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.delete_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_live_config_async_from_dict(): - await test_delete_live_config_async(request_type=dict) - -def test_delete_live_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteLiveConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_live_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteLiveConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_live_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_live_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_live_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_live_config( - video_stitcher_service.DeleteLiveConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_live_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_live_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_live_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_live_config( - video_stitcher_service.DeleteLiveConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateLiveConfigRequest, - dict, -]) -def test_update_live_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_live_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.UpdateLiveConfigRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_live_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.UpdateLiveConfigRequest( - ) - -def test_update_live_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_live_config] = mock_rpc - request = {} - client.update_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_live_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_live_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_live_config] = mock_rpc - - request = {} - await client.update_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.update_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_live_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateLiveConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.update_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateLiveConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_live_config_async_from_dict(): - await test_update_live_config_async(request_type=dict) - -def test_update_live_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateLiveConfigRequest() - - request.live_config.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'live_config.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_live_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateLiveConfigRequest() - - request.live_config.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'live_config.name=name_value', - ) in kw['metadata'] - - -def test_update_live_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_live_config( - live_config=live_configs.LiveConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].live_config - mock_val = live_configs.LiveConfig(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_live_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_live_config( - video_stitcher_service.UpdateLiveConfigRequest(), - live_config=live_configs.LiveConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_live_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_live_config( - live_config=live_configs.LiveConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].live_config - mock_val = live_configs.LiveConfig(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_live_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_live_config( - video_stitcher_service.UpdateLiveConfigRequest(), - live_config=live_configs.LiveConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateVodConfigRequest, - dict, -]) -def test_create_vod_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.create_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_create_vod_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.CreateVodConfigRequest( - parent='parent_value', - vod_config_id='vod_config_id_value', - request_id='request_id_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.create_vod_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.CreateVodConfigRequest( - parent='parent_value', - vod_config_id='vod_config_id_value', - request_id='request_id_value', - ) - -def test_create_vod_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_vod_config] = mock_rpc - request = {} - client.create_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.create_vod_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.create_vod_config] = mock_rpc - - request = {} - await client.create_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.create_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_create_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.CreateVodConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.create_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.CreateVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_create_vod_config_async_from_dict(): - await test_create_vod_config_async(request_type=dict) - -def test_create_vod_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateVodConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_create_vod_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.CreateVodConfigRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.create_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_create_vod_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_vod_config( - parent='parent_value', - vod_config=vod_configs.VodConfig(name='name_value'), - vod_config_id='vod_config_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].vod_config - mock_val = vod_configs.VodConfig(name='name_value') - assert arg == mock_val - arg = args[0].vod_config_id - mock_val = 'vod_config_id_value' - assert arg == mock_val - - -def test_create_vod_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_vod_config( - video_stitcher_service.CreateVodConfigRequest(), - parent='parent_value', - vod_config=vod_configs.VodConfig(name='name_value'), - vod_config_id='vod_config_id_value', - ) - -@pytest.mark.asyncio -async def test_create_vod_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_vod_config( - parent='parent_value', - vod_config=vod_configs.VodConfig(name='name_value'), - vod_config_id='vod_config_id_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - arg = args[0].vod_config - mock_val = vod_configs.VodConfig(name='name_value') - assert arg == mock_val - arg = args[0].vod_config_id - mock_val = 'vod_config_id_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_vod_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.create_vod_config( - video_stitcher_service.CreateVodConfigRequest(), - parent='parent_value', - vod_config=vod_configs.VodConfig(name='name_value'), - vod_config_id='vod_config_id_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListVodConfigsRequest, - dict, -]) -def test_list_vod_configs(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - response = client.list_vod_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListVodConfigsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -def test_list_vod_configs_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.ListVodConfigsRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.list_vod_configs(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.ListVodConfigsRequest( - parent='parent_value', - page_token='page_token_value', - filter='filter_value', - order_by='order_by_value', - ) - -def test_list_vod_configs_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_vod_configs in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_vod_configs] = mock_rpc - request = {} - client.list_vod_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_vod_configs(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_vod_configs_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.list_vod_configs in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.list_vod_configs] = mock_rpc - - request = {} - await client.list_vod_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.list_vod_configs(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_list_vod_configs_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.ListVodConfigsRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - response = await client.list_vod_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.ListVodConfigsRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodConfigsAsyncPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.asyncio -async def test_list_vod_configs_async_from_dict(): - await test_list_vod_configs_async(request_type=dict) - -def test_list_vod_configs_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListVodConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - call.return_value = video_stitcher_service.ListVodConfigsResponse() - client.list_vod_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_list_vod_configs_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.ListVodConfigsRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse()) - await client.list_vod_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'parent=parent_value', - ) in kw['metadata'] - - -def test_list_vod_configs_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodConfigsResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_vod_configs( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - - -def test_list_vod_configs_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_vod_configs( - video_stitcher_service.ListVodConfigsRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_vod_configs_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = video_stitcher_service.ListVodConfigsResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_vod_configs( - parent='parent_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].parent - mock_val = 'parent_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_list_vod_configs_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.list_vod_configs( - video_stitcher_service.ListVodConfigsRequest(), - parent='parent_value', - ) - - -def test_list_vod_configs_pager(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - ), - RuntimeError, - ) - - expected_metadata = () - retry = retries.Retry() - timeout = 5 - expected_metadata = tuple(expected_metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_vod_configs(request={}, retry=retry, timeout=timeout) - - assert pager._metadata == expected_metadata - assert pager._retry == retry - assert pager._timeout == timeout - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, vod_configs.VodConfig) - for i in results) -def test_list_vod_configs_pages(transport_name: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport_name, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - ), - RuntimeError, - ) - pages = list(client.list_vod_configs(request={}).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.asyncio -async def test_list_vod_configs_async_pager(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_vod_configs(request={},) - assert async_pager.next_page_token == 'abc' - responses = [] - async for response in async_pager: # pragma: no branch - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, vod_configs.VodConfig) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_vod_configs_async_pages(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - ), - RuntimeError, - ) - pages = [] - # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` - # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 - async for page_ in ( # pragma: no branch - await client.list_vod_configs(request={}) - ).pages: - pages.append(page_) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodConfigRequest, - dict, -]) -def test_get_vod_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = vod_configs.VodConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=vod_configs.VodConfig.State.CREATING, - ) - response = client.get_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, vod_configs.VodConfig) - assert response.name == 'name_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.state == vod_configs.VodConfig.State.CREATING - - -def test_get_vod_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.GetVodConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.get_vod_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.GetVodConfigRequest( - name='name_value', - ) - -def test_get_vod_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_config] = mock_rpc - request = {} - client.get_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.get_vod_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.get_vod_config] = mock_rpc - - request = {} - await client.get_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - await client.get_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_get_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.GetVodConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=vod_configs.VodConfig.State.CREATING, - )) - response = await client.get_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.GetVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, vod_configs.VodConfig) - assert response.name == 'name_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.state == vod_configs.VodConfig.State.CREATING - - -@pytest.mark.asyncio -async def test_get_vod_config_async_from_dict(): - await test_get_vod_config_async(request_type=dict) - -def test_get_vod_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - call.return_value = vod_configs.VodConfig() - client.get_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_get_vod_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.GetVodConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig()) - await client.get_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_get_vod_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = vod_configs.VodConfig() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_vod_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_get_vod_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_config( - video_stitcher_service.GetVodConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_vod_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = vod_configs.VodConfig() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_vod_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_get_vod_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.get_vod_config( - video_stitcher_service.GetVodConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteVodConfigRequest, - dict, -]) -def test_delete_vod_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.delete_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_delete_vod_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.DeleteVodConfigRequest( - name='name_value', - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.delete_vod_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.DeleteVodConfigRequest( - name='name_value', - ) - -def test_delete_vod_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_vod_config] = mock_rpc - request = {} - client.delete_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.delete_vod_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.delete_vod_config] = mock_rpc - - request = {} - await client.delete_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.delete_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_delete_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.DeleteVodConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.delete_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.DeleteVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_delete_vod_config_async_from_dict(): - await test_delete_vod_config_async(request_type=dict) - -def test_delete_vod_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteVodConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_delete_vod_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.DeleteVodConfigRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.delete_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'name=name_value', - ) in kw['metadata'] - - -def test_delete_vod_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.delete_vod_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - - -def test_delete_vod_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_vod_config( - video_stitcher_service.DeleteVodConfigRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_vod_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.delete_vod_config( - name='name_value', - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = 'name_value' - assert arg == mock_val - -@pytest.mark.asyncio -async def test_delete_vod_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.delete_vod_config( - video_stitcher_service.DeleteVodConfigRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateVodConfigRequest, - dict, -]) -def test_update_vod_config(request_type, transport: str = 'grpc'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/spam') - response = client.update_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_update_vod_config_non_empty_request_with_auto_populated_field(): - # This test is a coverage failsafe to make sure that UUID4 fields are - # automatically populated, according to AIP-4235, with non-empty requests. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - - # Populate all string fields in the request which are not UUID4 - # since we want to check that UUID4 are populated automatically - # if they meet the requirements of AIP 4235. - request = video_stitcher_service.UpdateVodConfigRequest( - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - call.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client.update_vod_config(request=request) - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == video_stitcher_service.UpdateVodConfigRequest( - ) - -def test_update_vod_config_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_vod_config] = mock_rpc - request = {} - client.update_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_vod_config_async_use_cached_wrapped_rpc(transport: str = "grpc_asyncio"): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method_async.wrap_method") as wrapper_fn: - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._client._transport.update_vod_config in client._client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.AsyncMock() - mock_rpc.return_value = mock.Mock() - client._client._transport._wrapped_methods[client._client._transport.update_vod_config] = mock_rpc - - request = {} - await client.update_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods call wrapper_fn to build a cached - # client._transport.operations_client instance on first rpc call. - # Subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - await client.update_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - -@pytest.mark.asyncio -async def test_update_vod_config_async(transport: str = 'grpc_asyncio', request_type=video_stitcher_service.UpdateVodConfigRequest): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - response = await client.update_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - request = video_stitcher_service.UpdateVodConfigRequest() - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_update_vod_config_async_from_dict(): - await test_update_vod_config_async(request_type=dict) - -def test_update_vod_config_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateVodConfigRequest() - - request.vod_config.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'vod_config.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_vod_config_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = video_stitcher_service.UpdateVodConfigRequest() - - request.vod_config.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(operations_pb2.Operation(name='operations/op')) - await client.update_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - 'x-goog-request-params', - 'vod_config.name=name_value', - ) in kw['metadata'] - - -def test_update_vod_config_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_vod_config( - vod_config=vod_configs.VodConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].vod_config - mock_val = vod_configs.VodConfig(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - - -def test_update_vod_config_flattened_error(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_vod_config( - video_stitcher_service.UpdateVodConfigRequest(), - vod_config=vod_configs.VodConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_vod_config_flattened_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name='operations/op') - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_vod_config( - vod_config=vod_configs.VodConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].vod_config - mock_val = vod_configs.VodConfig(name='name_value') - assert arg == mock_val - arg = args[0].update_mask - mock_val = field_mask_pb2.FieldMask(paths=['paths_value']) - assert arg == mock_val - -@pytest.mark.asyncio -async def test_update_vod_config_flattened_error_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.update_vod_config( - video_stitcher_service.UpdateVodConfigRequest(), - vod_config=vod_configs.VodConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_cdn_key_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_cdn_key] = mock_rpc - - request = {} - client.create_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_cdn_key_rest_required_fields(request_type=video_stitcher_service.CreateCdnKeyRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["cdn_key_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "cdnKeyId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_cdn_key._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "cdnKeyId" in jsonified_request - assert jsonified_request["cdnKeyId"] == request_init["cdn_key_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["cdnKeyId"] = 'cdn_key_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_cdn_key._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("cdn_key_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "cdnKeyId" in jsonified_request - assert jsonified_request["cdnKeyId"] == 'cdn_key_id_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_cdn_key(request) - - expected_params = [ - ( - "cdnKeyId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_cdn_key_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_cdn_key._get_unset_required_fields({}) - assert set(unset_fields) == (set(("cdnKeyId", )) & set(("parent", "cdnKey", "cdnKeyId", ))) - - -def test_create_cdn_key_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - cdn_key_id='cdn_key_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_cdn_key(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/cdnKeys" % client.transport._host, args[1]) - - -def test_create_cdn_key_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_cdn_key( - video_stitcher_service.CreateCdnKeyRequest(), - parent='parent_value', - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - cdn_key_id='cdn_key_id_value', - ) - - -def test_list_cdn_keys_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_cdn_keys in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_cdn_keys] = mock_rpc - - request = {} - client.list_cdn_keys(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_cdn_keys(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_cdn_keys_rest_required_fields(request_type=video_stitcher_service.ListCdnKeysRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_cdn_keys._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_cdn_keys._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListCdnKeysResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_cdn_keys(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_cdn_keys_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_cdn_keys._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_cdn_keys_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListCdnKeysResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_cdn_keys(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/cdnKeys" % client.transport._host, args[1]) - - -def test_list_cdn_keys_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_cdn_keys( - video_stitcher_service.ListCdnKeysRequest(), - parent='parent_value', - ) - - -def test_list_cdn_keys_rest_pager(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[], - next_page_token='def', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListCdnKeysResponse( - cdn_keys=[ - cdn_keys.CdnKey(), - cdn_keys.CdnKey(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(video_stitcher_service.ListCdnKeysResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_cdn_keys(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, cdn_keys.CdnKey) - for i in results) - - pages = list(client.list_cdn_keys(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_cdn_key_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_cdn_key] = mock_rpc - - request = {} - client.get_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_cdn_key_rest_required_fields(request_type=video_stitcher_service.GetCdnKeyRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_cdn_key._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_cdn_key._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = cdn_keys.CdnKey() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cdn_keys.CdnKey.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_cdn_key(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_cdn_key_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_cdn_key._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_cdn_key_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = cdn_keys.CdnKey() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = cdn_keys.CdnKey.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_cdn_key(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, args[1]) - - -def test_get_cdn_key_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_cdn_key( - video_stitcher_service.GetCdnKeyRequest(), - name='name_value', - ) - - -def test_delete_cdn_key_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_cdn_key] = mock_rpc - - request = {} - client.delete_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_cdn_key_rest_required_fields(request_type=video_stitcher_service.DeleteCdnKeyRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_cdn_key._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_cdn_key._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_cdn_key(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_cdn_key_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_cdn_key._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_cdn_key_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_cdn_key(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, args[1]) - - -def test_delete_cdn_key_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_cdn_key( - video_stitcher_service.DeleteCdnKeyRequest(), - name='name_value', - ) - - -def test_update_cdn_key_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_cdn_key in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_cdn_key] = mock_rpc - - request = {} - client.update_cdn_key(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_cdn_key(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_cdn_key_rest_required_fields(request_type=video_stitcher_service.UpdateCdnKeyRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_cdn_key._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_cdn_key._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_cdn_key(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_cdn_key_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_cdn_key._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("cdnKey", "updateMask", ))) - - -def test_update_cdn_key_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'cdn_key': {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_cdn_key(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{cdn_key.name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, args[1]) - - -def test_update_cdn_key_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_cdn_key( - video_stitcher_service.UpdateCdnKeyRequest(), - cdn_key=cdn_keys.CdnKey(google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b'private_key_blob')), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_vod_session_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_vod_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_vod_session] = mock_rpc - - request = {} - client.create_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_vod_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_vod_session_rest_required_fields(request_type=video_stitcher_service.CreateVodSessionRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = sessions.VodSession() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.VodSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_vod_session(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_vod_session_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_vod_session._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "vodSession", ))) - - -def test_create_vod_session_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.VodSession() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - vod_session=sessions.VodSession(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = sessions.VodSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_vod_session(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/vodSessions" % client.transport._host, args[1]) - - -def test_create_vod_session_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_vod_session( - video_stitcher_service.CreateVodSessionRequest(), - parent='parent_value', - vod_session=sessions.VodSession(name='name_value'), - ) - - -def test_get_vod_session_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_session] = mock_rpc - - request = {} - client.get_vod_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_vod_session_rest_required_fields(request_type=video_stitcher_service.GetVodSessionRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = sessions.VodSession() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.VodSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_vod_session(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_vod_session_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_vod_session._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_vod_session_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.VodSession() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = sessions.VodSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_vod_session(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodSessions/*}" % client.transport._host, args[1]) - - -def test_get_vod_session_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_session( - video_stitcher_service.GetVodSessionRequest(), - name='name_value', - ) - - -def test_list_vod_stitch_details_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_vod_stitch_details in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_vod_stitch_details] = mock_rpc - - request = {} - client.list_vod_stitch_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_vod_stitch_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_vod_stitch_details_rest_required_fields(request_type=video_stitcher_service.ListVodStitchDetailsRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_stitch_details._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_stitch_details._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodStitchDetailsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_vod_stitch_details(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_vod_stitch_details_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_vod_stitch_details._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_vod_stitch_details_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodStitchDetailsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_vod_stitch_details(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/vodSessions/*}/vodStitchDetails" % client.transport._host, args[1]) - - -def test_list_vod_stitch_details_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_vod_stitch_details( - video_stitcher_service.ListVodStitchDetailsRequest(), - parent='parent_value', - ) - - -def test_list_vod_stitch_details_rest_pager(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodStitchDetailsResponse( - vod_stitch_details=[ - stitch_details.VodStitchDetail(), - stitch_details.VodStitchDetail(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(video_stitcher_service.ListVodStitchDetailsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - - pager = client.list_vod_stitch_details(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, stitch_details.VodStitchDetail) - for i in results) - - pages = list(client.list_vod_stitch_details(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_vod_stitch_detail_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_stitch_detail in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_stitch_detail] = mock_rpc - - request = {} - client.get_vod_stitch_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_stitch_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_vod_stitch_detail_rest_required_fields(request_type=video_stitcher_service.GetVodStitchDetailRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_stitch_detail._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_stitch_detail._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = stitch_details.VodStitchDetail() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = stitch_details.VodStitchDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_vod_stitch_detail(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_vod_stitch_detail_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_vod_stitch_detail._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_vod_stitch_detail_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = stitch_details.VodStitchDetail() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = stitch_details.VodStitchDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_vod_stitch_detail(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodSessions/*/vodStitchDetails/*}" % client.transport._host, args[1]) - - -def test_get_vod_stitch_detail_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_stitch_detail( - video_stitcher_service.GetVodStitchDetailRequest(), - name='name_value', - ) - - -def test_list_vod_ad_tag_details_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_vod_ad_tag_details in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_vod_ad_tag_details] = mock_rpc - - request = {} - client.list_vod_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_vod_ad_tag_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_vod_ad_tag_details_rest_required_fields(request_type=video_stitcher_service.ListVodAdTagDetailsRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_ad_tag_details._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_ad_tag_details._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_vod_ad_tag_details(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_vod_ad_tag_details_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_vod_ad_tag_details._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_vod_ad_tag_details_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_vod_ad_tag_details(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/vodSessions/*}/vodAdTagDetails" % client.transport._host, args[1]) - - -def test_list_vod_ad_tag_details_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_vod_ad_tag_details( - video_stitcher_service.ListVodAdTagDetailsRequest(), - parent='parent_value', - ) - - -def test_list_vod_ad_tag_details_rest_pager(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodAdTagDetailsResponse( - vod_ad_tag_details=[ - ad_tag_details.VodAdTagDetail(), - ad_tag_details.VodAdTagDetail(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(video_stitcher_service.ListVodAdTagDetailsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - - pager = client.list_vod_ad_tag_details(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, ad_tag_details.VodAdTagDetail) - for i in results) - - pages = list(client.list_vod_ad_tag_details(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_vod_ad_tag_detail_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_ad_tag_detail in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_ad_tag_detail] = mock_rpc - - request = {} - client.get_vod_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_ad_tag_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_vod_ad_tag_detail_rest_required_fields(request_type=video_stitcher_service.GetVodAdTagDetailRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_ad_tag_detail._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_ad_tag_detail._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = ad_tag_details.VodAdTagDetail() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = ad_tag_details.VodAdTagDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_vod_ad_tag_detail(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_vod_ad_tag_detail_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_vod_ad_tag_detail._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_vod_ad_tag_detail_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = ad_tag_details.VodAdTagDetail() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = ad_tag_details.VodAdTagDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_vod_ad_tag_detail(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodSessions/*/vodAdTagDetails/*}" % client.transport._host, args[1]) - - -def test_get_vod_ad_tag_detail_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_ad_tag_detail( - video_stitcher_service.GetVodAdTagDetailRequest(), - name='name_value', - ) - - -def test_list_live_ad_tag_details_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_live_ad_tag_details in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_live_ad_tag_details] = mock_rpc - - request = {} - client.list_live_ad_tag_details(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_live_ad_tag_details(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_live_ad_tag_details_rest_required_fields(request_type=video_stitcher_service.ListLiveAdTagDetailsRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_ad_tag_details._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_ad_tag_details._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_live_ad_tag_details(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_live_ad_tag_details_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_live_ad_tag_details._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_live_ad_tag_details_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_live_ad_tag_details(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*/liveSessions/*}/liveAdTagDetails" % client.transport._host, args[1]) - - -def test_list_live_ad_tag_details_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_live_ad_tag_details( - video_stitcher_service.ListLiveAdTagDetailsRequest(), - parent='parent_value', - ) - - -def test_list_live_ad_tag_details_rest_pager(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveAdTagDetailsResponse( - live_ad_tag_details=[ - ad_tag_details.LiveAdTagDetail(), - ad_tag_details.LiveAdTagDetail(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(video_stitcher_service.ListLiveAdTagDetailsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} - - pager = client.list_live_ad_tag_details(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, ad_tag_details.LiveAdTagDetail) - for i in results) - - pages = list(client.list_live_ad_tag_details(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_live_ad_tag_detail_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_live_ad_tag_detail in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_live_ad_tag_detail] = mock_rpc - - request = {} - client.get_live_ad_tag_detail(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_live_ad_tag_detail(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_live_ad_tag_detail_rest_required_fields(request_type=video_stitcher_service.GetLiveAdTagDetailRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_ad_tag_detail._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_ad_tag_detail._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = ad_tag_details.LiveAdTagDetail() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_live_ad_tag_detail(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_live_ad_tag_detail_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_live_ad_tag_detail._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_live_ad_tag_detail_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = ad_tag_details.LiveAdTagDetail() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_live_ad_tag_detail(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveSessions/*/liveAdTagDetails/*}" % client.transport._host, args[1]) - - -def test_get_live_ad_tag_detail_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_live_ad_tag_detail( - video_stitcher_service.GetLiveAdTagDetailRequest(), - name='name_value', - ) - - -def test_create_slate_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_slate] = mock_rpc - - request = {} - client.create_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_slate_rest_required_fields(request_type=video_stitcher_service.CreateSlateRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["slate_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "slateId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_slate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "slateId" in jsonified_request - assert jsonified_request["slateId"] == request_init["slate_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["slateId"] = 'slate_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_slate._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("request_id", "slate_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "slateId" in jsonified_request - assert jsonified_request["slateId"] == 'slate_id_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_slate(request) - - expected_params = [ - ( - "slateId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_slate_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_slate._get_unset_required_fields({}) - assert set(unset_fields) == (set(("requestId", "slateId", )) & set(("parent", "slateId", "slate", ))) - - -def test_create_slate_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - slate=slates.Slate(name='name_value'), - slate_id='slate_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_slate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/slates" % client.transport._host, args[1]) - - -def test_create_slate_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_slate( - video_stitcher_service.CreateSlateRequest(), - parent='parent_value', - slate=slates.Slate(name='name_value'), - slate_id='slate_id_value', - ) - - -def test_list_slates_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_slates in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_slates] = mock_rpc - - request = {} - client.list_slates(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_slates(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_slates_rest_required_fields(request_type=video_stitcher_service.ListSlatesRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_slates._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_slates._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListSlatesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_slates(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_slates_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_slates._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_slates_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListSlatesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_slates(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/slates" % client.transport._host, args[1]) - - -def test_list_slates_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_slates( - video_stitcher_service.ListSlatesRequest(), - parent='parent_value', - ) - - -def test_list_slates_rest_pager(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - slates.Slate(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListSlatesResponse( - slates=[], - next_page_token='def', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListSlatesResponse( - slates=[ - slates.Slate(), - slates.Slate(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(video_stitcher_service.ListSlatesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_slates(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, slates.Slate) - for i in results) - - pages = list(client.list_slates(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_slate_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_slate] = mock_rpc - - request = {} - client.get_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_slate_rest_required_fields(request_type=video_stitcher_service.GetSlateRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_slate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_slate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = slates.Slate() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = slates.Slate.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_slate(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_slate_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_slate._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_slate_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = slates.Slate() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/slates/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = slates.Slate.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_slate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/slates/*}" % client.transport._host, args[1]) - - -def test_get_slate_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_slate( - video_stitcher_service.GetSlateRequest(), - name='name_value', - ) - - -def test_update_slate_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_slate] = mock_rpc - - request = {} - client.update_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_slate_rest_required_fields(request_type=video_stitcher_service.UpdateSlateRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_slate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_slate._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_slate(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_slate_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_slate._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("slate", "updateMask", ))) - - -def test_update_slate_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'slate': {'name': 'projects/sample1/locations/sample2/slates/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - slate=slates.Slate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_slate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{slate.name=projects/*/locations/*/slates/*}" % client.transport._host, args[1]) - - -def test_update_slate_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_slate( - video_stitcher_service.UpdateSlateRequest(), - slate=slates.Slate(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_delete_slate_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_slate in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_slate] = mock_rpc - - request = {} - client.delete_slate(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_slate(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_slate_rest_required_fields(request_type=video_stitcher_service.DeleteSlateRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_slate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_slate._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_slate(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_slate_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_slate._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_slate_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/slates/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_slate(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/slates/*}" % client.transport._host, args[1]) - - -def test_delete_slate_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_slate( - video_stitcher_service.DeleteSlateRequest(), - name='name_value', - ) - - -def test_create_live_session_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_live_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_live_session] = mock_rpc - - request = {} - client.create_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.create_live_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_live_session_rest_required_fields(request_type=video_stitcher_service.CreateLiveSessionRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = sessions.LiveSession() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.LiveSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_live_session(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_live_session_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_live_session._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "liveSession", ))) - - -def test_create_live_session_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.LiveSession() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - live_session=sessions.LiveSession(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = sessions.LiveSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_live_session(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/liveSessions" % client.transport._host, args[1]) - - -def test_create_live_session_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_live_session( - video_stitcher_service.CreateLiveSessionRequest(), - parent='parent_value', - live_session=sessions.LiveSession(name='name_value'), - ) - - -def test_get_live_session_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_live_session in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_live_session] = mock_rpc - - request = {} - client.get_live_session(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_live_session(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_live_session_rest_required_fields(request_type=video_stitcher_service.GetLiveSessionRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_session._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = sessions.LiveSession() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.LiveSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_live_session(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_live_session_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_live_session._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_live_session_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.LiveSession() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = sessions.LiveSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_live_session(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveSessions/*}" % client.transport._host, args[1]) - - -def test_get_live_session_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_live_session( - video_stitcher_service.GetLiveSessionRequest(), - name='name_value', - ) - - -def test_create_live_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_live_config] = mock_rpc - - request = {} - client.create_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_live_config_rest_required_fields(request_type=video_stitcher_service.CreateLiveConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["live_config_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "liveConfigId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "liveConfigId" in jsonified_request - assert jsonified_request["liveConfigId"] == request_init["live_config_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["liveConfigId"] = 'live_config_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_live_config._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("live_config_id", "request_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "liveConfigId" in jsonified_request - assert jsonified_request["liveConfigId"] == 'live_config_id_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_live_config(request) - - expected_params = [ - ( - "liveConfigId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_live_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_live_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("liveConfigId", "requestId", )) & set(("parent", "liveConfigId", "liveConfig", ))) - - -def test_create_live_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - live_config=live_configs.LiveConfig(name='name_value'), - live_config_id='live_config_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_live_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/liveConfigs" % client.transport._host, args[1]) - - -def test_create_live_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_live_config( - video_stitcher_service.CreateLiveConfigRequest(), - parent='parent_value', - live_config=live_configs.LiveConfig(name='name_value'), - live_config_id='live_config_id_value', - ) - - -def test_list_live_configs_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_live_configs in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_live_configs] = mock_rpc - - request = {} - client.list_live_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_live_configs(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_live_configs_rest_required_fields(request_type=video_stitcher_service.ListLiveConfigsRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_configs._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_live_configs._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListLiveConfigsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_live_configs(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_live_configs_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_live_configs._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_live_configs_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListLiveConfigsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_live_configs(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/liveConfigs" % client.transport._host, args[1]) - - -def test_list_live_configs_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_live_configs( - video_stitcher_service.ListLiveConfigsRequest(), - parent='parent_value', - ) - - -def test_list_live_configs_rest_pager(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListLiveConfigsResponse( - live_configs=[ - live_configs.LiveConfig(), - live_configs.LiveConfig(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(video_stitcher_service.ListLiveConfigsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_live_configs(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, live_configs.LiveConfig) - for i in results) - - pages = list(client.list_live_configs(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_live_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_live_config] = mock_rpc - - request = {} - client.get_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_live_config_rest_required_fields(request_type=video_stitcher_service.GetLiveConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_live_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = live_configs.LiveConfig() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = live_configs.LiveConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_live_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_live_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_live_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_live_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = live_configs.LiveConfig() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = live_configs.LiveConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_live_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveConfigs/*}" % client.transport._host, args[1]) - - -def test_get_live_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_live_config( - video_stitcher_service.GetLiveConfigRequest(), - name='name_value', - ) - - -def test_delete_live_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_live_config] = mock_rpc - - request = {} - client.delete_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_live_config_rest_required_fields(request_type=video_stitcher_service.DeleteLiveConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_live_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_live_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_live_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_live_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_live_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_live_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_live_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/liveConfigs/*}" % client.transport._host, args[1]) - - -def test_delete_live_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_live_config( - video_stitcher_service.DeleteLiveConfigRequest(), - name='name_value', - ) - - -def test_update_live_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_live_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_live_config] = mock_rpc - - request = {} - client.update_live_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_live_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_live_config_rest_required_fields(request_type=video_stitcher_service.UpdateLiveConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_live_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_live_config._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_live_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_live_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_live_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("liveConfig", "updateMask", ))) - - -def test_update_live_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'live_config': {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - live_config=live_configs.LiveConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_live_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{live_config.name=projects/*/locations/*/liveConfigs/*}" % client.transport._host, args[1]) - - -def test_update_live_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_live_config( - video_stitcher_service.UpdateLiveConfigRequest(), - live_config=live_configs.LiveConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_create_vod_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.create_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.create_vod_config] = mock_rpc - - request = {} - client.create_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.create_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_create_vod_config_rest_required_fields(request_type=video_stitcher_service.CreateVodConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["vod_config_id"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - assert "vodConfigId" not in jsonified_request - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - assert "vodConfigId" in jsonified_request - assert jsonified_request["vodConfigId"] == request_init["vod_config_id"] - - jsonified_request["parent"] = 'parent_value' - jsonified_request["vodConfigId"] = 'vod_config_id_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_vod_config._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("request_id", "vod_config_id", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "vodConfigId" in jsonified_request - assert jsonified_request["vodConfigId"] == 'vod_config_id_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.create_vod_config(request) - - expected_params = [ - ( - "vodConfigId", - "", - ), - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_vod_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_vod_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("requestId", "vodConfigId", )) & set(("parent", "vodConfigId", "vodConfig", ))) - - -def test_create_vod_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - vod_config=vod_configs.VodConfig(name='name_value'), - vod_config_id='vod_config_id_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.create_vod_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/vodConfigs" % client.transport._host, args[1]) - - -def test_create_vod_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_vod_config( - video_stitcher_service.CreateVodConfigRequest(), - parent='parent_value', - vod_config=vod_configs.VodConfig(name='name_value'), - vod_config_id='vod_config_id_value', - ) - - -def test_list_vod_configs_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.list_vod_configs in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.list_vod_configs] = mock_rpc - - request = {} - client.list_vod_configs(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.list_vod_configs(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_list_vod_configs_rest_required_fields(request_type=video_stitcher_service.ListVodConfigsRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_configs._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_vod_configs._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("filter", "order_by", "page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodConfigsResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_vod_configs(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_vod_configs_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_vod_configs._get_unset_required_fields({}) - assert set(unset_fields) == (set(("filter", "orderBy", "pageSize", "pageToken", )) & set(("parent", ))) - - -def test_list_vod_configs_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodConfigsResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.list_vod_configs(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/vodConfigs" % client.transport._host, args[1]) - - -def test_list_vod_configs_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_vod_configs( - video_stitcher_service.ListVodConfigsRequest(), - parent='parent_value', - ) - - -def test_list_vod_configs_rest_pager(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - next_page_token='abc', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[], - next_page_token='def', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - ], - next_page_token='ghi', - ), - video_stitcher_service.ListVodConfigsResponse( - vod_configs=[ - vod_configs.VodConfig(), - vod_configs.VodConfig(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(video_stitcher_service.ListVodConfigsResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_vod_configs(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, vod_configs.VodConfig) - for i in results) - - pages = list(client.list_vod_configs(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -def test_get_vod_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.get_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.get_vod_config] = mock_rpc - - request = {} - client.get_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - client.get_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_get_vod_config_rest_required_fields(request_type=video_stitcher_service.GetVodConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_vod_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = vod_configs.VodConfig() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = vod_configs.VodConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_vod_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_vod_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_vod_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_get_vod_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = vod_configs.VodConfig() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = vod_configs.VodConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.get_vod_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, args[1]) - - -def test_get_vod_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_vod_config( - video_stitcher_service.GetVodConfigRequest(), - name='name_value', - ) - - -def test_delete_vod_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.delete_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.delete_vod_config] = mock_rpc - - request = {} - client.delete_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.delete_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_delete_vod_config_rest_required_fields(request_type=video_stitcher_service.DeleteVodConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_vod_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_vod_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_vod_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_vod_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_vod_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -def test_delete_vod_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.delete_vod_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, args[1]) - - -def test_delete_vod_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_vod_config( - video_stitcher_service.DeleteVodConfigRequest(), - name='name_value', - ) - - -def test_update_vod_config_rest_use_cached_wrapped_rpc(): - # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, - # instead of constructing them on each call - with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Should wrap all calls on client creation - assert wrapper_fn.call_count > 0 - wrapper_fn.reset_mock() - - # Ensure method has been cached - assert client._transport.update_vod_config in client._transport._wrapped_methods - - # Replace cached wrapped function with mock - mock_rpc = mock.Mock() - mock_rpc.return_value.name = "foo" # operation_request.operation in compute client(s) expect a string. - client._transport._wrapped_methods[client._transport.update_vod_config] = mock_rpc - - request = {} - client.update_vod_config(request) - - # Establish that the underlying gRPC stub method was called. - assert mock_rpc.call_count == 1 - - # Operation methods build a cached wrapper on first rpc call - # subsequent calls should use the cached wrapper - wrapper_fn.reset_mock() - - client.update_vod_config(request) - - # Establish that a new wrapper was not created for this call - assert wrapper_fn.call_count == 0 - assert mock_rpc.call_count == 2 - - -def test_update_vod_config_rest_required_fields(request_type=video_stitcher_service.UpdateVodConfigRequest): - transport_class = transports.VideoStitcherServiceRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_vod_config._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_vod_config._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.update_vod_config(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_vod_config_rest_unset_required_fields(): - transport = transports.VideoStitcherServiceRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_vod_config._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", )) & set(("vodConfig", "updateMask", ))) - - -def test_update_vod_config_rest_flattened(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # get arguments that satisfy an http rule for this method - sample_request = {'vod_config': {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - vod_config=vod_configs.VodConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - client.update_vod_config(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{vod_config.name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, args[1]) - - -def test_update_vod_config_rest_flattened_error(transport: str = 'rest'): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_vod_config( - video_stitcher_service.UpdateVodConfigRequest(), - vod_config=vod_configs.VodConfig(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = VideoStitcherServiceClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.VideoStitcherServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.VideoStitcherServiceGrpcTransport, - transports.VideoStitcherServiceGrpcAsyncIOTransport, - transports.VideoStitcherServiceRestTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -def test_transport_kind_grpc(): - transport = VideoStitcherServiceClient.get_transport_class("grpc")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" - - -def test_initialize_client_w_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_cdn_key_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_cdn_keys_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - call.return_value = video_stitcher_service.ListCdnKeysResponse() - client.list_cdn_keys(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListCdnKeysRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_cdn_key_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - call.return_value = cdn_keys.CdnKey() - client.get_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_cdn_key_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_cdn_key_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_vod_session_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - call.return_value = sessions.VodSession() - client.create_vod_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_session_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - call.return_value = sessions.VodSession() - client.get_vod_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_stitch_details_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() - client.list_vod_stitch_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodStitchDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_stitch_detail_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - call.return_value = stitch_details.VodStitchDetail() - client.get_vod_stitch_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodStitchDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_ad_tag_details_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - client.list_vod_ad_tag_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_ad_tag_detail_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - call.return_value = ad_tag_details.VodAdTagDetail() - client.get_vod_ad_tag_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodAdTagDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_live_ad_tag_details_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - client.list_live_ad_tag_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_ad_tag_detail_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - call.return_value = ad_tag_details.LiveAdTagDetail() - client.get_live_ad_tag_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_slate_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_slates_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - call.return_value = video_stitcher_service.ListSlatesResponse() - client.list_slates(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListSlatesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_slate_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - call.return_value = slates.Slate() - client.get_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_slate_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_slate_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_live_session_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - call.return_value = sessions.LiveSession() - client.create_live_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_session_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - call.return_value = sessions.LiveSession() - client.get_live_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_live_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_live_configs_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - call.return_value = video_stitcher_service.ListLiveConfigsResponse() - client.list_live_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveConfigsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - call.return_value = live_configs.LiveConfig() - client.get_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_live_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_live_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_vod_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.create_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_configs_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - call.return_value = video_stitcher_service.ListVodConfigsResponse() - client.list_vod_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodConfigsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - call.return_value = vod_configs.VodConfig() - client.get_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_vod_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.delete_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_vod_config_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - call.return_value = operations_pb2.Operation(name='operations/op') - client.update_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateVodConfigRequest() - - assert args[0] == request_msg - - -def test_transport_kind_grpc_asyncio(): - transport = VideoStitcherServiceAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" - - -def test_initialize_client_w_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.create_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_cdn_keys_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListCdnKeysResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_cdn_keys(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListCdnKeysRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cdn_keys.CdnKey( - name='name_value', - hostname='hostname_value', - )) - await client.get_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.delete_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.update_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_vod_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - )) - await client.create_vod_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - )) - await client.get_vod_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_vod_stitch_details_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodStitchDetailsResponse( - next_page_token='next_page_token_value', - )) - await client.list_vod_stitch_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodStitchDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(stitch_details.VodStitchDetail( - name='name_value', - )) - await client.get_vod_stitch_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodStitchDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodAdTagDetailsResponse( - next_page_token='next_page_token_value', - )) - await client.list_vod_ad_tag_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.VodAdTagDetail( - name='name_value', - )) - await client.get_vod_ad_tag_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodAdTagDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveAdTagDetailsResponse( - next_page_token='next_page_token_value', - )) - await client.list_live_ad_tag_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ad_tag_details.LiveAdTagDetail( - name='name_value', - )) - await client.get_live_ad_tag_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.create_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_slates_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListSlatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_slates(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListSlatesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(slates.Slate( - name='name_value', - uri='uri_value', - )) - await client.get_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.update_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.delete_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_live_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - )) - await client.create_live_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_live_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - )) - await client.get_live_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.create_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_live_configs_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListLiveConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_live_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveConfigsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(live_configs.LiveConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=live_configs.LiveConfig.State.CREATING, - ad_tracking=live_configs.AdTracking.CLIENT, - default_slate='default_slate_value', - stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, - )) - await client.get_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.delete_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.update_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.create_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_vod_configs_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(video_stitcher_service.ListVodConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - )) - await client.list_vod_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodConfigsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(vod_configs.VodConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=vod_configs.VodConfig.State.CREATING, - )) - await client.get_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.delete_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name='operations/spam') - ) - await client.update_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateVodConfigRequest() - - assert args[0] == request_msg - - -def test_transport_kind_rest(): - transport = VideoStitcherServiceClient.get_transport_class("rest")( - credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "rest" - - -def test_create_cdn_key_rest_bad_request(request_type=video_stitcher_service.CreateCdnKeyRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_cdn_key(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateCdnKeyRequest, - dict, -]) -def test_create_cdn_key_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["cdn_key"] = {'google_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value'}, 'akamai_cdn_key': {'token_key': b'token_key_blob'}, 'media_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value', 'token_config': {'query_parameter': 'query_parameter_value'}}, 'name': 'name_value', 'hostname': 'hostname_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.CreateCdnKeyRequest.meta.fields["cdn_key"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["cdn_key"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["cdn_key"][field])): - del request_init["cdn_key"][field][i][subfield] - else: - del request_init["cdn_key"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_cdn_key(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_cdn_key_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_cdn_key") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_cdn_key_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_cdn_key") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.CreateCdnKeyRequest.pb(video_stitcher_service.CreateCdnKeyRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.CreateCdnKeyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_cdn_keys_rest_bad_request(request_type=video_stitcher_service.ListCdnKeysRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_cdn_keys(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListCdnKeysRequest, - dict, -]) -def test_list_cdn_keys_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListCdnKeysResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_cdn_keys(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCdnKeysPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_cdn_keys_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_cdn_keys") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_cdn_keys_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_cdn_keys") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.ListCdnKeysRequest.pb(video_stitcher_service.ListCdnKeysRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = video_stitcher_service.ListCdnKeysResponse.to_json(video_stitcher_service.ListCdnKeysResponse()) - req.return_value.content = return_value - - request = video_stitcher_service.ListCdnKeysRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = video_stitcher_service.ListCdnKeysResponse() - post_with_metadata.return_value = video_stitcher_service.ListCdnKeysResponse(), metadata - - client.list_cdn_keys(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_cdn_key_rest_bad_request(request_type=video_stitcher_service.GetCdnKeyRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_cdn_key(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetCdnKeyRequest, - dict, -]) -def test_get_cdn_key_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = cdn_keys.CdnKey( - name='name_value', - hostname='hostname_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = cdn_keys.CdnKey.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_cdn_key(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, cdn_keys.CdnKey) - assert response.name == 'name_value' - assert response.hostname == 'hostname_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_cdn_key_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_cdn_key") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_cdn_key_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_cdn_key") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetCdnKeyRequest.pb(video_stitcher_service.GetCdnKeyRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = cdn_keys.CdnKey.to_json(cdn_keys.CdnKey()) - req.return_value.content = return_value - - request = video_stitcher_service.GetCdnKeyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = cdn_keys.CdnKey() - post_with_metadata.return_value = cdn_keys.CdnKey(), metadata - - client.get_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_cdn_key_rest_bad_request(request_type=video_stitcher_service.DeleteCdnKeyRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_cdn_key(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteCdnKeyRequest, - dict, -]) -def test_delete_cdn_key_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_cdn_key(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_cdn_key_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_cdn_key") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_cdn_key_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_cdn_key") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.DeleteCdnKeyRequest.pb(video_stitcher_service.DeleteCdnKeyRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.DeleteCdnKeyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_cdn_key_rest_bad_request(request_type=video_stitcher_service.UpdateCdnKeyRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'cdn_key': {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_cdn_key(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateCdnKeyRequest, - dict, -]) -def test_update_cdn_key_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'cdn_key': {'name': 'projects/sample1/locations/sample2/cdnKeys/sample3'}} - request_init["cdn_key"] = {'google_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value'}, 'akamai_cdn_key': {'token_key': b'token_key_blob'}, 'media_cdn_key': {'private_key': b'private_key_blob', 'key_name': 'key_name_value', 'token_config': {'query_parameter': 'query_parameter_value'}}, 'name': 'projects/sample1/locations/sample2/cdnKeys/sample3', 'hostname': 'hostname_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.UpdateCdnKeyRequest.meta.fields["cdn_key"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["cdn_key"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["cdn_key"][field])): - del request_init["cdn_key"][field][i][subfield] - else: - del request_init["cdn_key"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_cdn_key(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_cdn_key_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_cdn_key") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_cdn_key_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_cdn_key") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.UpdateCdnKeyRequest.pb(video_stitcher_service.UpdateCdnKeyRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.UpdateCdnKeyRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_cdn_key(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_vod_session_rest_bad_request(request_type=video_stitcher_service.CreateVodSessionRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_vod_session(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateVodSessionRequest, - dict, -]) -def test_create_vod_session_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["vod_session"] = {'name': 'name_value', 'interstitials': {'ad_breaks': [{'progress_events': [{'time_offset': {'seconds': 751, 'nanos': 543}, 'events': [{'type_': 1, 'uri': 'uri_value', 'id': 'id_value', 'offset': {}}]}], 'ads': [{'duration': {}, 'companion_ads': {'display_requirement': 1, 'companions': [{'iframe_ad_resource': {'uri': 'uri_value'}, 'static_ad_resource': {'uri': 'uri_value', 'creative_type': 'creative_type_value'}, 'html_ad_resource': {'html_source': 'html_source_value'}, 'api_framework': 'api_framework_value', 'height_px': 960, 'width_px': 871, 'asset_height_px': 1599, 'expanded_height_px': 1896, 'asset_width_px': 1510, 'expanded_width_px': 1807, 'ad_slot_id': 'ad_slot_id_value', 'events': {}}]}, 'activity_events': {}}], 'end_time_offset': {}, 'start_time_offset': {}}], 'session_content': {'duration': {}}}, 'play_uri': 'play_uri_value', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'ad_tag_macro_map': {}, 'manifest_options': {'include_renditions': [{'bitrate_bps': 1167, 'codecs': 'codecs_value'}], 'bitrate_order': 1}, 'asset_id': 'asset_id_value', 'ad_tracking': 1, 'gam_settings': {'network_code': 'network_code_value', 'stream_id': 'stream_id_value'}, 'vod_config': 'vod_config_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.CreateVodSessionRequest.meta.fields["vod_session"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["vod_session"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["vod_session"][field])): - del request_init["vod_session"][field][i][subfield] - else: - del request_init["vod_session"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.VodSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_vod_session(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.VodSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.asset_id == 'asset_id_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.vod_config == 'vod_config_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_vod_session_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_session") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_session_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_vod_session") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.CreateVodSessionRequest.pb(video_stitcher_service.CreateVodSessionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = sessions.VodSession.to_json(sessions.VodSession()) - req.return_value.content = return_value - - request = video_stitcher_service.CreateVodSessionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = sessions.VodSession() - post_with_metadata.return_value = sessions.VodSession(), metadata - - client.create_vod_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_vod_session_rest_bad_request(request_type=video_stitcher_service.GetVodSessionRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_vod_session(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodSessionRequest, - dict, -]) -def test_get_vod_session_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.VodSession( - name='name_value', - play_uri='play_uri_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - asset_id='asset_id_value', - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config='vod_config_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.VodSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_vod_session(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.VodSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.asset_id == 'asset_id_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.vod_config == 'vod_config_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_vod_session_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_session") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_session_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_session") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetVodSessionRequest.pb(video_stitcher_service.GetVodSessionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = sessions.VodSession.to_json(sessions.VodSession()) - req.return_value.content = return_value - - request = video_stitcher_service.GetVodSessionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = sessions.VodSession() - post_with_metadata.return_value = sessions.VodSession(), metadata - - client.get_vod_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_vod_stitch_details_rest_bad_request(request_type=video_stitcher_service.ListVodStitchDetailsRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_vod_stitch_details(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListVodStitchDetailsRequest, - dict, -]) -def test_list_vod_stitch_details_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodStitchDetailsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_vod_stitch_details(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodStitchDetailsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_vod_stitch_details_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_stitch_details") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_stitch_details_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_stitch_details") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.ListVodStitchDetailsRequest.pb(video_stitcher_service.ListVodStitchDetailsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = video_stitcher_service.ListVodStitchDetailsResponse.to_json(video_stitcher_service.ListVodStitchDetailsResponse()) - req.return_value.content = return_value - - request = video_stitcher_service.ListVodStitchDetailsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = video_stitcher_service.ListVodStitchDetailsResponse() - post_with_metadata.return_value = video_stitcher_service.ListVodStitchDetailsResponse(), metadata - - client.list_vod_stitch_details(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_vod_stitch_detail_rest_bad_request(request_type=video_stitcher_service.GetVodStitchDetailRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_vod_stitch_detail(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodStitchDetailRequest, - dict, -]) -def test_get_vod_stitch_detail_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = stitch_details.VodStitchDetail( - name='name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = stitch_details.VodStitchDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_vod_stitch_detail(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, stitch_details.VodStitchDetail) - assert response.name == 'name_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_vod_stitch_detail_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_stitch_detail") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_stitch_detail_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_stitch_detail") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetVodStitchDetailRequest.pb(video_stitcher_service.GetVodStitchDetailRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = stitch_details.VodStitchDetail.to_json(stitch_details.VodStitchDetail()) - req.return_value.content = return_value - - request = video_stitcher_service.GetVodStitchDetailRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = stitch_details.VodStitchDetail() - post_with_metadata.return_value = stitch_details.VodStitchDetail(), metadata - - client.get_vod_stitch_detail(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_vod_ad_tag_details_rest_bad_request(request_type=video_stitcher_service.ListVodAdTagDetailsRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_vod_ad_tag_details(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListVodAdTagDetailsRequest, - dict, -]) -def test_list_vod_ad_tag_details_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/vodSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodAdTagDetailsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_vod_ad_tag_details(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodAdTagDetailsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_vod_ad_tag_details_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_ad_tag_details") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_ad_tag_details_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_ad_tag_details") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.ListVodAdTagDetailsRequest.pb(video_stitcher_service.ListVodAdTagDetailsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = video_stitcher_service.ListVodAdTagDetailsResponse.to_json(video_stitcher_service.ListVodAdTagDetailsResponse()) - req.return_value.content = return_value - - request = video_stitcher_service.ListVodAdTagDetailsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - post_with_metadata.return_value = video_stitcher_service.ListVodAdTagDetailsResponse(), metadata - - client.list_vod_ad_tag_details(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_vod_ad_tag_detail_rest_bad_request(request_type=video_stitcher_service.GetVodAdTagDetailRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_vod_ad_tag_detail(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodAdTagDetailRequest, - dict, -]) -def test_get_vod_ad_tag_detail_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = ad_tag_details.VodAdTagDetail( - name='name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = ad_tag_details.VodAdTagDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_vod_ad_tag_detail(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, ad_tag_details.VodAdTagDetail) - assert response.name == 'name_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_vod_ad_tag_detail_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_ad_tag_detail") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_ad_tag_detail_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_ad_tag_detail") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetVodAdTagDetailRequest.pb(video_stitcher_service.GetVodAdTagDetailRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = ad_tag_details.VodAdTagDetail.to_json(ad_tag_details.VodAdTagDetail()) - req.return_value.content = return_value - - request = video_stitcher_service.GetVodAdTagDetailRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = ad_tag_details.VodAdTagDetail() - post_with_metadata.return_value = ad_tag_details.VodAdTagDetail(), metadata - - client.get_vod_ad_tag_detail(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_live_ad_tag_details_rest_bad_request(request_type=video_stitcher_service.ListLiveAdTagDetailsRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_live_ad_tag_details(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListLiveAdTagDetailsRequest, - dict, -]) -def test_list_live_ad_tag_details_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2/liveSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListLiveAdTagDetailsResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_live_ad_tag_details(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListLiveAdTagDetailsPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_live_ad_tag_details_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_ad_tag_details") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_ad_tag_details_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_live_ad_tag_details") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.ListLiveAdTagDetailsRequest.pb(video_stitcher_service.ListLiveAdTagDetailsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.to_json(video_stitcher_service.ListLiveAdTagDetailsResponse()) - req.return_value.content = return_value - - request = video_stitcher_service.ListLiveAdTagDetailsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - post_with_metadata.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse(), metadata - - client.list_live_ad_tag_details(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_live_ad_tag_detail_rest_bad_request(request_type=video_stitcher_service.GetLiveAdTagDetailRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_live_ad_tag_detail(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetLiveAdTagDetailRequest, - dict, -]) -def test_get_live_ad_tag_detail_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = ad_tag_details.LiveAdTagDetail( - name='name_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_live_ad_tag_detail(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, ad_tag_details.LiveAdTagDetail) - assert response.name == 'name_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_live_ad_tag_detail_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_ad_tag_detail") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_ad_tag_detail_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_live_ad_tag_detail") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetLiveAdTagDetailRequest.pb(video_stitcher_service.GetLiveAdTagDetailRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = ad_tag_details.LiveAdTagDetail.to_json(ad_tag_details.LiveAdTagDetail()) - req.return_value.content = return_value - - request = video_stitcher_service.GetLiveAdTagDetailRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = ad_tag_details.LiveAdTagDetail() - post_with_metadata.return_value = ad_tag_details.LiveAdTagDetail(), metadata - - client.get_live_ad_tag_detail(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_slate_rest_bad_request(request_type=video_stitcher_service.CreateSlateRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_slate(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateSlateRequest, - dict, -]) -def test_create_slate_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["slate"] = {'name': 'name_value', 'uri': 'uri_value', 'gam_slate': {'network_code': 'network_code_value', 'gam_slate_id': 1241}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.CreateSlateRequest.meta.fields["slate"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["slate"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["slate"][field])): - del request_init["slate"][field][i][subfield] - else: - del request_init["slate"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_slate(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_slate_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_slate") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_slate_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_slate") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.CreateSlateRequest.pb(video_stitcher_service.CreateSlateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.CreateSlateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_slates_rest_bad_request(request_type=video_stitcher_service.ListSlatesRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_slates(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListSlatesRequest, - dict, -]) -def test_list_slates_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListSlatesResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_slates(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSlatesPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_slates_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_slates") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_slates_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_slates") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.ListSlatesRequest.pb(video_stitcher_service.ListSlatesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = video_stitcher_service.ListSlatesResponse.to_json(video_stitcher_service.ListSlatesResponse()) - req.return_value.content = return_value - - request = video_stitcher_service.ListSlatesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = video_stitcher_service.ListSlatesResponse() - post_with_metadata.return_value = video_stitcher_service.ListSlatesResponse(), metadata - - client.list_slates(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_slate_rest_bad_request(request_type=video_stitcher_service.GetSlateRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_slate(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetSlateRequest, - dict, -]) -def test_get_slate_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = slates.Slate( - name='name_value', - uri='uri_value', - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = slates.Slate.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_slate(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, slates.Slate) - assert response.name == 'name_value' - assert response.uri == 'uri_value' - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_slate_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_slate") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_slate_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_slate") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetSlateRequest.pb(video_stitcher_service.GetSlateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = slates.Slate.to_json(slates.Slate()) - req.return_value.content = return_value - - request = video_stitcher_service.GetSlateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = slates.Slate() - post_with_metadata.return_value = slates.Slate(), metadata - - client.get_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_slate_rest_bad_request(request_type=video_stitcher_service.UpdateSlateRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'slate': {'name': 'projects/sample1/locations/sample2/slates/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_slate(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateSlateRequest, - dict, -]) -def test_update_slate_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'slate': {'name': 'projects/sample1/locations/sample2/slates/sample3'}} - request_init["slate"] = {'name': 'projects/sample1/locations/sample2/slates/sample3', 'uri': 'uri_value', 'gam_slate': {'network_code': 'network_code_value', 'gam_slate_id': 1241}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.UpdateSlateRequest.meta.fields["slate"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["slate"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["slate"][field])): - del request_init["slate"][field][i][subfield] - else: - del request_init["slate"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_slate(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_slate_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_slate") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_slate_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_slate") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.UpdateSlateRequest.pb(video_stitcher_service.UpdateSlateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.UpdateSlateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_slate_rest_bad_request(request_type=video_stitcher_service.DeleteSlateRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_slate(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteSlateRequest, - dict, -]) -def test_delete_slate_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/slates/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_slate(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_slate_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_slate") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_slate_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_slate") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.DeleteSlateRequest.pb(video_stitcher_service.DeleteSlateRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.DeleteSlateRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_slate(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_live_session_rest_bad_request(request_type=video_stitcher_service.CreateLiveSessionRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_live_session(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateLiveSessionRequest, - dict, -]) -def test_create_live_session_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["live_session"] = {'name': 'name_value', 'play_uri': 'play_uri_value', 'ad_tag_macros': {}, 'manifest_options': {'include_renditions': [{'bitrate_bps': 1167, 'codecs': 'codecs_value'}], 'bitrate_order': 1}, 'gam_settings': {'stream_id': 'stream_id_value', 'targeting_parameters': {}}, 'live_config': 'live_config_value', 'ad_tracking': 1} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.CreateLiveSessionRequest.meta.fields["live_session"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["live_session"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["live_session"][field])): - del request_init["live_session"][field][i][subfield] - else: - del request_init["live_session"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.LiveSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_live_session(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.LiveSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.live_config == 'live_config_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_live_session_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_session") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_session_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_live_session") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.CreateLiveSessionRequest.pb(video_stitcher_service.CreateLiveSessionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = sessions.LiveSession.to_json(sessions.LiveSession()) - req.return_value.content = return_value - - request = video_stitcher_service.CreateLiveSessionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = sessions.LiveSession() - post_with_metadata.return_value = sessions.LiveSession(), metadata - - client.create_live_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_live_session_rest_bad_request(request_type=video_stitcher_service.GetLiveSessionRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_live_session(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetLiveSessionRequest, - dict, -]) -def test_get_live_session_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveSessions/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = sessions.LiveSession( - name='name_value', - play_uri='play_uri_value', - live_config='live_config_value', - ad_tracking=live_configs.AdTracking.CLIENT, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = sessions.LiveSession.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_live_session(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, sessions.LiveSession) - assert response.name == 'name_value' - assert response.play_uri == 'play_uri_value' - assert response.live_config == 'live_config_value' - assert response.ad_tracking == live_configs.AdTracking.CLIENT - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_live_session_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_session") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_session_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_live_session") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetLiveSessionRequest.pb(video_stitcher_service.GetLiveSessionRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = sessions.LiveSession.to_json(sessions.LiveSession()) - req.return_value.content = return_value - - request = video_stitcher_service.GetLiveSessionRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = sessions.LiveSession() - post_with_metadata.return_value = sessions.LiveSession(), metadata - - client.get_live_session(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_live_config_rest_bad_request(request_type=video_stitcher_service.CreateLiveConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_live_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateLiveConfigRequest, - dict, -]) -def test_create_live_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["live_config"] = {'name': 'name_value', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_live_config': {'network_code': 'network_code_value', 'asset_key': 'asset_key_value', 'custom_asset_key': 'custom_asset_key_value'}, 'state': 1, 'ad_tracking': 1, 'default_slate': 'default_slate_value', 'stitching_policy': 1, 'prefetch_config': {'enabled': True, 'initial_ad_request_duration': {'seconds': 751, 'nanos': 543}}, 'source_fetch_options': {'headers': {}}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.CreateLiveConfigRequest.meta.fields["live_config"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["live_config"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["live_config"][field])): - del request_init["live_config"][field][i][subfield] - else: - del request_init["live_config"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_live_config(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_live_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_live_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_live_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.CreateLiveConfigRequest.pb(video_stitcher_service.CreateLiveConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.CreateLiveConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_live_configs_rest_bad_request(request_type=video_stitcher_service.ListLiveConfigsRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_live_configs(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListLiveConfigsRequest, - dict, -]) -def test_list_live_configs_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListLiveConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_live_configs(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListLiveConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_live_configs_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_configs") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_live_configs_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_live_configs") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.ListLiveConfigsRequest.pb(video_stitcher_service.ListLiveConfigsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = video_stitcher_service.ListLiveConfigsResponse.to_json(video_stitcher_service.ListLiveConfigsResponse()) - req.return_value.content = return_value - - request = video_stitcher_service.ListLiveConfigsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = video_stitcher_service.ListLiveConfigsResponse() - post_with_metadata.return_value = video_stitcher_service.ListLiveConfigsResponse(), metadata - - client.list_live_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_live_config_rest_bad_request(request_type=video_stitcher_service.GetLiveConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_live_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetLiveConfigRequest, - dict, -]) -def test_get_live_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = live_configs.LiveConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=live_configs.LiveConfig.State.CREATING, - ad_tracking=live_configs.AdTracking.CLIENT, - default_slate='default_slate_value', - stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = live_configs.LiveConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_live_config(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, live_configs.LiveConfig) - assert response.name == 'name_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.state == live_configs.LiveConfig.State.CREATING - assert response.ad_tracking == live_configs.AdTracking.CLIENT - assert response.default_slate == 'default_slate_value' - assert response.stitching_policy == live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_live_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_live_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_live_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetLiveConfigRequest.pb(video_stitcher_service.GetLiveConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = live_configs.LiveConfig.to_json(live_configs.LiveConfig()) - req.return_value.content = return_value - - request = video_stitcher_service.GetLiveConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = live_configs.LiveConfig() - post_with_metadata.return_value = live_configs.LiveConfig(), metadata - - client.get_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_live_config_rest_bad_request(request_type=video_stitcher_service.DeleteLiveConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_live_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteLiveConfigRequest, - dict, -]) -def test_delete_live_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_live_config(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_live_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_live_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_live_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_live_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.DeleteLiveConfigRequest.pb(video_stitcher_service.DeleteLiveConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.DeleteLiveConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_live_config_rest_bad_request(request_type=video_stitcher_service.UpdateLiveConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'live_config': {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_live_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateLiveConfigRequest, - dict, -]) -def test_update_live_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'live_config': {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3'}} - request_init["live_config"] = {'name': 'projects/sample1/locations/sample2/liveConfigs/sample3', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_live_config': {'network_code': 'network_code_value', 'asset_key': 'asset_key_value', 'custom_asset_key': 'custom_asset_key_value'}, 'state': 1, 'ad_tracking': 1, 'default_slate': 'default_slate_value', 'stitching_policy': 1, 'prefetch_config': {'enabled': True, 'initial_ad_request_duration': {'seconds': 751, 'nanos': 543}}, 'source_fetch_options': {'headers': {}}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.UpdateLiveConfigRequest.meta.fields["live_config"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["live_config"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["live_config"][field])): - del request_init["live_config"][field][i][subfield] - else: - del request_init["live_config"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_live_config(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_live_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_live_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_live_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_live_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.UpdateLiveConfigRequest.pb(video_stitcher_service.UpdateLiveConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.UpdateLiveConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_live_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_create_vod_config_rest_bad_request(request_type=video_stitcher_service.CreateVodConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.create_vod_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.CreateVodConfigRequest, - dict, -]) -def test_create_vod_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["vod_config"] = {'name': 'name_value', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_vod_config': {'network_code': 'network_code_value'}, 'state': 1, 'source_fetch_options': {'headers': {}}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.CreateVodConfigRequest.meta.fields["vod_config"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["vod_config"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["vod_config"][field])): - del request_init["vod_config"][field][i][subfield] - else: - del request_init["vod_config"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.create_vod_config(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_vod_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_create_vod_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_create_vod_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.CreateVodConfigRequest.pb(video_stitcher_service.CreateVodConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.CreateVodConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.create_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_list_vod_configs_rest_bad_request(request_type=video_stitcher_service.ListVodConfigsRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_vod_configs(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.ListVodConfigsRequest, - dict, -]) -def test_list_vod_configs_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = video_stitcher_service.ListVodConfigsResponse( - next_page_token='next_page_token_value', - unreachable=['unreachable_value'], - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.list_vod_configs(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListVodConfigsPager) - assert response.next_page_token == 'next_page_token_value' - assert response.unreachable == ['unreachable_value'] - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_vod_configs_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_configs") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_list_vod_configs_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_configs") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.ListVodConfigsRequest.pb(video_stitcher_service.ListVodConfigsRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = video_stitcher_service.ListVodConfigsResponse.to_json(video_stitcher_service.ListVodConfigsResponse()) - req.return_value.content = return_value - - request = video_stitcher_service.ListVodConfigsRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = video_stitcher_service.ListVodConfigsResponse() - post_with_metadata.return_value = video_stitcher_service.ListVodConfigsResponse(), metadata - - client.list_vod_configs(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_get_vod_config_rest_bad_request(request_type=video_stitcher_service.GetVodConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_vod_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.GetVodConfigRequest, - dict, -]) -def test_get_vod_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = vod_configs.VodConfig( - name='name_value', - source_uri='source_uri_value', - ad_tag_uri='ad_tag_uri_value', - state=vod_configs.VodConfig.State.CREATING, - ) - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = vod_configs.VodConfig.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.get_vod_config(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, vod_configs.VodConfig) - assert response.name == 'name_value' - assert response.source_uri == 'source_uri_value' - assert response.ad_tag_uri == 'ad_tag_uri_value' - assert response.state == vod_configs.VodConfig.State.CREATING - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_vod_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_get_vod_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.GetVodConfigRequest.pb(video_stitcher_service.GetVodConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = vod_configs.VodConfig.to_json(vod_configs.VodConfig()) - req.return_value.content = return_value - - request = video_stitcher_service.GetVodConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = vod_configs.VodConfig() - post_with_metadata.return_value = vod_configs.VodConfig(), metadata - - client.get_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_delete_vod_config_rest_bad_request(request_type=video_stitcher_service.DeleteVodConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_vod_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.DeleteVodConfigRequest, - dict, -]) -def test_delete_vod_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.delete_vod_config(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_vod_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_vod_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_delete_vod_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_delete_vod_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.DeleteVodConfigRequest.pb(video_stitcher_service.DeleteVodConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.DeleteVodConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.delete_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_update_vod_config_rest_bad_request(request_type=video_stitcher_service.UpdateVodConfigRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - # send a request that will satisfy transcoding - request_init = {'vod_config': {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = mock.Mock() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = mock.Mock() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.update_vod_config(request) - - -@pytest.mark.parametrize("request_type", [ - video_stitcher_service.UpdateVodConfigRequest, - dict, -]) -def test_update_vod_config_rest_call_success(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - - # send a request that will satisfy transcoding - request_init = {'vod_config': {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3'}} - request_init["vod_config"] = {'name': 'projects/sample1/locations/sample2/vodConfigs/sample3', 'source_uri': 'source_uri_value', 'ad_tag_uri': 'ad_tag_uri_value', 'gam_vod_config': {'network_code': 'network_code_value'}, 'state': 1, 'source_fetch_options': {'headers': {}}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = video_stitcher_service.UpdateVodConfigRequest.meta.fields["vod_config"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["vod_config"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["vod_config"][field])): - del request_init["vod_config"][field][i][subfield] - else: - del request_init["vod_config"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation(name='operations/spam') - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - response = client.update_vod_config(request) - - # Establish that the response is the type that we expect. - json_return_value = json_format.MessageToJson(return_value) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_vod_config_rest_interceptors(null_interceptor): - transport = transports.VideoStitcherServiceRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.VideoStitcherServiceRestInterceptor(), - ) - client = VideoStitcherServiceClient(transport=transport) - - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(operation.Operation, "_set_result_from_operation"), \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_vod_config") as post, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "post_update_vod_config_with_metadata") as post_with_metadata, \ - mock.patch.object(transports.VideoStitcherServiceRestInterceptor, "pre_update_vod_config") as pre: - pre.assert_not_called() - post.assert_not_called() - post_with_metadata.assert_not_called() - pb_message = video_stitcher_service.UpdateVodConfigRequest.pb(video_stitcher_service.UpdateVodConfigRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = mock.Mock() - req.return_value.status_code = 200 - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - return_value = json_format.MessageToJson(operations_pb2.Operation()) - req.return_value.content = return_value - - request = video_stitcher_service.UpdateVodConfigRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = operations_pb2.Operation() - post_with_metadata.return_value = operations_pb2.Operation(), metadata - - client.update_vod_config(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - post_with_metadata.assert_called_once() - - -def test_cancel_operation_rest_bad_request(request_type=operations_pb2.CancelOperationRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.cancel_operation(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.CancelOperationRequest, - dict, -]) -def test_cancel_operation_rest(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = '{}' - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.cancel_operation(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_operation_rest_bad_request(request_type=operations_pb2.DeleteOperationRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.delete_operation(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.DeleteOperationRequest, - dict, -]) -def test_delete_operation_rest(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = '{}' - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.delete_operation(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_get_operation_rest_bad_request(request_type=operations_pb2.GetOperationRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2/operations/sample3'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.get_operation(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.GetOperationRequest, - dict, -]) -def test_get_operation_rest(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1/locations/sample2/operations/sample3'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.Operation() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.get_operation(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - - -def test_list_operations_rest_bad_request(request_type=operations_pb2.ListOperationsRequest): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - json_return_value = '' - response_value.json = mock.Mock(return_value={}) - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - client.list_operations(request) - - -@pytest.mark.parametrize("request_type", [ - operations_pb2.ListOperationsRequest, - dict, -]) -def test_list_operations_rest(request_type): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - request_init = {'name': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # Designate an appropriate value for the returned response. - return_value = operations_pb2.ListOperationsResponse() - - # Wrap the value into a proper Response obj - response_value = mock.Mock() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - response_value.content = json_return_value.encode('UTF-8') - - req.return_value = response_value - req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} - - response = client.list_operations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) - -def test_initialize_client_w_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - assert client is not None - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_cdn_key_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_cdn_key), - '__call__') as call: - client.create_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_cdn_keys_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_cdn_keys), - '__call__') as call: - client.list_cdn_keys(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListCdnKeysRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_cdn_key_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_cdn_key), - '__call__') as call: - client.get_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_cdn_key_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_cdn_key), - '__call__') as call: - client.delete_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_cdn_key_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_cdn_key), - '__call__') as call: - client.update_cdn_key(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateCdnKeyRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_vod_session_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_session), - '__call__') as call: - client.create_vod_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_session_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_session), - '__call__') as call: - client.get_vod_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_stitch_details_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_stitch_details), - '__call__') as call: - client.list_vod_stitch_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodStitchDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_stitch_detail_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_stitch_detail), - '__call__') as call: - client.get_vod_stitch_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodStitchDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_ad_tag_details_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), - '__call__') as call: - client.list_vod_ad_tag_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_ad_tag_detail_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), - '__call__') as call: - client.get_vod_ad_tag_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodAdTagDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_live_ad_tag_details_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), - '__call__') as call: - client.list_live_ad_tag_details(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_ad_tag_detail_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), - '__call__') as call: - client.get_live_ad_tag_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_slate_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_slate), - '__call__') as call: - client.create_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_slates_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_slates), - '__call__') as call: - client.list_slates(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListSlatesRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_slate_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_slate), - '__call__') as call: - client.get_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_slate_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_slate), - '__call__') as call: - client.update_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_slate_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_slate), - '__call__') as call: - client.delete_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteSlateRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_live_session_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_live_session), - '__call__') as call: - client.create_live_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_session_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_session), - '__call__') as call: - client.get_live_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveSessionRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_live_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), - '__call__') as call: - client.create_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_live_configs_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_live_configs), - '__call__') as call: - client.list_live_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveConfigsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_live_config), - '__call__') as call: - client.get_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_live_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), - '__call__') as call: - client.delete_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_live_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), - '__call__') as call: - client.update_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateLiveConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_vod_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), - '__call__') as call: - client.create_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_configs_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_vod_configs), - '__call__') as call: - client.list_vod_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodConfigsRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_config), - '__call__') as call: - client.get_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_vod_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), - '__call__') as call: - client.delete_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteVodConfigRequest() - - assert args[0] == request_msg - - -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_vod_config_empty_call_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), - '__call__') as call: - client.update_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateVodConfigRequest() - - assert args[0] == request_msg - - -def test_video_stitcher_service_rest_lro_client(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - transport = client.transport - - # Ensure that we have an api-core operations client. - assert isinstance( - transport.operations_client, -operations_v1.AbstractOperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.VideoStitcherServiceGrpcTransport, - ) - -def test_video_stitcher_service_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.VideoStitcherServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_video_stitcher_service_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.VideoStitcherServiceTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'create_cdn_key', - 'list_cdn_keys', - 'get_cdn_key', - 'delete_cdn_key', - 'update_cdn_key', - 'create_vod_session', - 'get_vod_session', - 'list_vod_stitch_details', - 'get_vod_stitch_detail', - 'list_vod_ad_tag_details', - 'get_vod_ad_tag_detail', - 'list_live_ad_tag_details', - 'get_live_ad_tag_detail', - 'create_slate', - 'list_slates', - 'get_slate', - 'update_slate', - 'delete_slate', - 'create_live_session', - 'get_live_session', - 'create_live_config', - 'list_live_configs', - 'get_live_config', - 'delete_live_config', - 'update_live_config', - 'create_vod_config', - 'list_vod_configs', - 'get_vod_config', - 'delete_vod_config', - 'update_vod_config', - 'get_operation', - 'cancel_operation', - 'delete_operation', - 'list_operations', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Additionally, the LRO client (a property) should - # also raise NotImplementedError - with pytest.raises(NotImplementedError): - transport.operations_client - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_video_stitcher_service_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.VideoStitcherServiceTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -def test_video_stitcher_service_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.video.stitcher_v1.services.video_stitcher_service.transports.VideoStitcherServiceTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.VideoStitcherServiceTransport() - adc.assert_called_once() - - -def test_video_stitcher_service_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - VideoStitcherServiceClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.VideoStitcherServiceGrpcTransport, - transports.VideoStitcherServiceGrpcAsyncIOTransport, - ], -) -def test_video_stitcher_service_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.VideoStitcherServiceGrpcTransport, - transports.VideoStitcherServiceGrpcAsyncIOTransport, - transports.VideoStitcherServiceRestTransport, - ], -) -def test_video_stitcher_service_transport_auth_gdch_credentials(transport_class): - host = 'https://language.com' - api_audience_tests = [None, 'https://language2.com'] - api_audience_expect = [host, 'https://language2.com'] - for t, e in zip(api_audience_tests, api_audience_expect): - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - gdch_mock = mock.MagicMock() - type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) - adc.return_value = (gdch_mock, None) - transport_class(host=host, api_audience=t) - gdch_mock.with_gdch_audience.assert_called_once_with( - e - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.VideoStitcherServiceGrpcTransport, grpc_helpers), - (transports.VideoStitcherServiceGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_video_stitcher_service_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "videostitcher.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=["1", "2"], - default_host="videostitcher.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.VideoStitcherServiceGrpcTransport, transports.VideoStitcherServiceGrpcAsyncIOTransport]) -def test_video_stitcher_service_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - -def test_video_stitcher_service_http_transport_client_cert_source_for_mtls(): - cred = ga_credentials.AnonymousCredentials() - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: - transports.VideoStitcherServiceRestTransport ( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) - - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_video_stitcher_service_host_no_port(transport_name): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='videostitcher.googleapis.com'), - transport=transport_name, - ) - assert client.transport._host == ( - 'videostitcher.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://videostitcher.googleapis.com' - ) - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_video_stitcher_service_host_with_port(transport_name): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='videostitcher.googleapis.com:8000'), - transport=transport_name, - ) - assert client.transport._host == ( - 'videostitcher.googleapis.com:8000' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://videostitcher.googleapis.com:8000' - ) - -@pytest.mark.parametrize("transport_name", [ - "rest", -]) -def test_video_stitcher_service_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = VideoStitcherServiceClient( - credentials=creds1, - transport=transport_name, - ) - client2 = VideoStitcherServiceClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.create_cdn_key._session - session2 = client2.transport.create_cdn_key._session - assert session1 != session2 - session1 = client1.transport.list_cdn_keys._session - session2 = client2.transport.list_cdn_keys._session - assert session1 != session2 - session1 = client1.transport.get_cdn_key._session - session2 = client2.transport.get_cdn_key._session - assert session1 != session2 - session1 = client1.transport.delete_cdn_key._session - session2 = client2.transport.delete_cdn_key._session - assert session1 != session2 - session1 = client1.transport.update_cdn_key._session - session2 = client2.transport.update_cdn_key._session - assert session1 != session2 - session1 = client1.transport.create_vod_session._session - session2 = client2.transport.create_vod_session._session - assert session1 != session2 - session1 = client1.transport.get_vod_session._session - session2 = client2.transport.get_vod_session._session - assert session1 != session2 - session1 = client1.transport.list_vod_stitch_details._session - session2 = client2.transport.list_vod_stitch_details._session - assert session1 != session2 - session1 = client1.transport.get_vod_stitch_detail._session - session2 = client2.transport.get_vod_stitch_detail._session - assert session1 != session2 - session1 = client1.transport.list_vod_ad_tag_details._session - session2 = client2.transport.list_vod_ad_tag_details._session - assert session1 != session2 - session1 = client1.transport.get_vod_ad_tag_detail._session - session2 = client2.transport.get_vod_ad_tag_detail._session - assert session1 != session2 - session1 = client1.transport.list_live_ad_tag_details._session - session2 = client2.transport.list_live_ad_tag_details._session - assert session1 != session2 - session1 = client1.transport.get_live_ad_tag_detail._session - session2 = client2.transport.get_live_ad_tag_detail._session - assert session1 != session2 - session1 = client1.transport.create_slate._session - session2 = client2.transport.create_slate._session - assert session1 != session2 - session1 = client1.transport.list_slates._session - session2 = client2.transport.list_slates._session - assert session1 != session2 - session1 = client1.transport.get_slate._session - session2 = client2.transport.get_slate._session - assert session1 != session2 - session1 = client1.transport.update_slate._session - session2 = client2.transport.update_slate._session - assert session1 != session2 - session1 = client1.transport.delete_slate._session - session2 = client2.transport.delete_slate._session - assert session1 != session2 - session1 = client1.transport.create_live_session._session - session2 = client2.transport.create_live_session._session - assert session1 != session2 - session1 = client1.transport.get_live_session._session - session2 = client2.transport.get_live_session._session - assert session1 != session2 - session1 = client1.transport.create_live_config._session - session2 = client2.transport.create_live_config._session - assert session1 != session2 - session1 = client1.transport.list_live_configs._session - session2 = client2.transport.list_live_configs._session - assert session1 != session2 - session1 = client1.transport.get_live_config._session - session2 = client2.transport.get_live_config._session - assert session1 != session2 - session1 = client1.transport.delete_live_config._session - session2 = client2.transport.delete_live_config._session - assert session1 != session2 - session1 = client1.transport.update_live_config._session - session2 = client2.transport.update_live_config._session - assert session1 != session2 - session1 = client1.transport.create_vod_config._session - session2 = client2.transport.create_vod_config._session - assert session1 != session2 - session1 = client1.transport.list_vod_configs._session - session2 = client2.transport.list_vod_configs._session - assert session1 != session2 - session1 = client1.transport.get_vod_config._session - session2 = client2.transport.get_vod_config._session - assert session1 != session2 - session1 = client1.transport.delete_vod_config._session - session2 = client2.transport.delete_vod_config._session - assert session1 != session2 - session1 = client1.transport.update_vod_config._session - session2 = client2.transport.update_vod_config._session - assert session1 != session2 -def test_video_stitcher_service_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.VideoStitcherServiceGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_video_stitcher_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.VideoStitcherServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.VideoStitcherServiceGrpcTransport, transports.VideoStitcherServiceGrpcAsyncIOTransport]) -def test_video_stitcher_service_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.VideoStitcherServiceGrpcTransport, transports.VideoStitcherServiceGrpcAsyncIOTransport]) -def test_video_stitcher_service_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_video_stitcher_service_grpc_lro_client(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_video_stitcher_service_grpc_lro_async_client(): - client = VideoStitcherServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='grpc_asyncio', - ) - transport = client.transport - - # Ensure that we have a api-core operations client. - assert isinstance( - transport.operations_client, - operations_v1.OperationsAsyncClient, - ) - - # Ensure that subsequent calls to the property send the exact same object. - assert transport.operations_client is transport.operations_client - - -def test_cdn_key_path(): - project = "squid" - location = "clam" - cdn_key = "whelk" - expected = "projects/{project}/locations/{location}/cdnKeys/{cdn_key}".format(project=project, location=location, cdn_key=cdn_key, ) - actual = VideoStitcherServiceClient.cdn_key_path(project, location, cdn_key) - assert expected == actual - - -def test_parse_cdn_key_path(): - expected = { - "project": "octopus", - "location": "oyster", - "cdn_key": "nudibranch", - } - path = VideoStitcherServiceClient.cdn_key_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_cdn_key_path(path) - assert expected == actual - -def test_live_ad_tag_detail_path(): - project = "cuttlefish" - location = "mussel" - live_session = "winkle" - live_ad_tag_detail = "nautilus" - expected = "projects/{project}/locations/{location}/liveSessions/{live_session}/liveAdTagDetails/{live_ad_tag_detail}".format(project=project, location=location, live_session=live_session, live_ad_tag_detail=live_ad_tag_detail, ) - actual = VideoStitcherServiceClient.live_ad_tag_detail_path(project, location, live_session, live_ad_tag_detail) - assert expected == actual - - -def test_parse_live_ad_tag_detail_path(): - expected = { - "project": "scallop", - "location": "abalone", - "live_session": "squid", - "live_ad_tag_detail": "clam", - } - path = VideoStitcherServiceClient.live_ad_tag_detail_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_live_ad_tag_detail_path(path) - assert expected == actual - -def test_live_config_path(): - project = "whelk" - location = "octopus" - live_config = "oyster" - expected = "projects/{project}/locations/{location}/liveConfigs/{live_config}".format(project=project, location=location, live_config=live_config, ) - actual = VideoStitcherServiceClient.live_config_path(project, location, live_config) - assert expected == actual - - -def test_parse_live_config_path(): - expected = { - "project": "nudibranch", - "location": "cuttlefish", - "live_config": "mussel", - } - path = VideoStitcherServiceClient.live_config_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_live_config_path(path) - assert expected == actual - -def test_live_session_path(): - project = "winkle" - location = "nautilus" - live_session = "scallop" - expected = "projects/{project}/locations/{location}/liveSessions/{live_session}".format(project=project, location=location, live_session=live_session, ) - actual = VideoStitcherServiceClient.live_session_path(project, location, live_session) - assert expected == actual - - -def test_parse_live_session_path(): - expected = { - "project": "abalone", - "location": "squid", - "live_session": "clam", - } - path = VideoStitcherServiceClient.live_session_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_live_session_path(path) - assert expected == actual - -def test_slate_path(): - project = "whelk" - location = "octopus" - slate = "oyster" - expected = "projects/{project}/locations/{location}/slates/{slate}".format(project=project, location=location, slate=slate, ) - actual = VideoStitcherServiceClient.slate_path(project, location, slate) - assert expected == actual - - -def test_parse_slate_path(): - expected = { - "project": "nudibranch", - "location": "cuttlefish", - "slate": "mussel", - } - path = VideoStitcherServiceClient.slate_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_slate_path(path) - assert expected == actual - -def test_vod_ad_tag_detail_path(): - project = "winkle" - location = "nautilus" - vod_session = "scallop" - vod_ad_tag_detail = "abalone" - expected = "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodAdTagDetails/{vod_ad_tag_detail}".format(project=project, location=location, vod_session=vod_session, vod_ad_tag_detail=vod_ad_tag_detail, ) - actual = VideoStitcherServiceClient.vod_ad_tag_detail_path(project, location, vod_session, vod_ad_tag_detail) - assert expected == actual - - -def test_parse_vod_ad_tag_detail_path(): - expected = { - "project": "squid", - "location": "clam", - "vod_session": "whelk", - "vod_ad_tag_detail": "octopus", - } - path = VideoStitcherServiceClient.vod_ad_tag_detail_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_vod_ad_tag_detail_path(path) - assert expected == actual - -def test_vod_config_path(): - project = "oyster" - location = "nudibranch" - vod_config = "cuttlefish" - expected = "projects/{project}/locations/{location}/vodConfigs/{vod_config}".format(project=project, location=location, vod_config=vod_config, ) - actual = VideoStitcherServiceClient.vod_config_path(project, location, vod_config) - assert expected == actual - - -def test_parse_vod_config_path(): - expected = { - "project": "mussel", - "location": "winkle", - "vod_config": "nautilus", - } - path = VideoStitcherServiceClient.vod_config_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_vod_config_path(path) - assert expected == actual - -def test_vod_session_path(): - project = "scallop" - location = "abalone" - vod_session = "squid" - expected = "projects/{project}/locations/{location}/vodSessions/{vod_session}".format(project=project, location=location, vod_session=vod_session, ) - actual = VideoStitcherServiceClient.vod_session_path(project, location, vod_session) - assert expected == actual - - -def test_parse_vod_session_path(): - expected = { - "project": "clam", - "location": "whelk", - "vod_session": "octopus", - } - path = VideoStitcherServiceClient.vod_session_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_vod_session_path(path) - assert expected == actual - -def test_vod_stitch_detail_path(): - project = "oyster" - location = "nudibranch" - vod_session = "cuttlefish" - vod_stitch_detail = "mussel" - expected = "projects/{project}/locations/{location}/vodSessions/{vod_session}/vodStitchDetails/{vod_stitch_detail}".format(project=project, location=location, vod_session=vod_session, vod_stitch_detail=vod_stitch_detail, ) - actual = VideoStitcherServiceClient.vod_stitch_detail_path(project, location, vod_session, vod_stitch_detail) - assert expected == actual - - -def test_parse_vod_stitch_detail_path(): - expected = { - "project": "winkle", - "location": "nautilus", - "vod_session": "scallop", - "vod_stitch_detail": "abalone", - } - path = VideoStitcherServiceClient.vod_stitch_detail_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_vod_stitch_detail_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "squid" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = VideoStitcherServiceClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "clam", - } - path = VideoStitcherServiceClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "whelk" - expected = "folders/{folder}".format(folder=folder, ) - actual = VideoStitcherServiceClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "octopus", - } - path = VideoStitcherServiceClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "oyster" - expected = "organizations/{organization}".format(organization=organization, ) - actual = VideoStitcherServiceClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "nudibranch", - } - path = VideoStitcherServiceClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "cuttlefish" - expected = "projects/{project}".format(project=project, ) - actual = VideoStitcherServiceClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "mussel", - } - path = VideoStitcherServiceClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "winkle" - location = "nautilus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = VideoStitcherServiceClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "scallop", - "location": "abalone", - } - path = VideoStitcherServiceClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = VideoStitcherServiceClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.VideoStitcherServiceTransport, '_prep_wrapped_messages') as prep: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.VideoStitcherServiceTransport, '_prep_wrapped_messages') as prep: - transport_class = VideoStitcherServiceClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - -def test_delete_operation(transport: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.DeleteOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None -@pytest.mark.asyncio -async def test_delete_operation_async(transport: str = "grpc_asyncio"): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.DeleteOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.delete_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - -def test_delete_operation_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.DeleteOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - call.return_value = None - - client.delete_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_delete_operation_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.DeleteOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - await client.delete_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] - -def test_delete_operation_from_dict(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.delete_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_delete_operation_from_dict_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.delete_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.delete_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_cancel_operation(transport: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None -@pytest.mark.asyncio -async def test_cancel_operation_async(transport: str = "grpc_asyncio"): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.CancelOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert response is None - -def test_cancel_operation_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = None - - client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_cancel_operation_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.CancelOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - await client.cancel_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] - -def test_cancel_operation_from_dict(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = None - - response = client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_cancel_operation_from_dict_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.cancel_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - None - ) - response = await client.cancel_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_operation(transport: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.GetOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation() - response = client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) -@pytest.mark.asyncio -async def test_get_operation_async(transport: str = "grpc_asyncio"): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.GetOperationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - response = await client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.Operation) - -def test_get_operation_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.GetOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - call.return_value = operations_pb2.Operation() - - client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_get_operation_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.GetOperationRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - await client.get_operation(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] - -def test_get_operation_from_dict(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation() - - response = client.get_operation( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_get_operation_from_dict_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_operation), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation() - ) - response = await client.get_operation( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_list_operations(transport: str = "grpc"): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - response = client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) -@pytest.mark.asyncio -async def test_list_operations_async(transport: str = "grpc_asyncio"): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = operations_pb2.ListOperationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the response is the type that we expect. - assert isinstance(response, operations_pb2.ListOperationsResponse) - -def test_list_operations_field_headers(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = operations_pb2.ListOperationsResponse() - - client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_list_operations_field_headers_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = operations_pb2.ListOperationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - await client.list_operations(request) - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=locations",) in kw["metadata"] - -def test_list_operations_from_dict(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.ListOperationsResponse() - - response = client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_operations_from_dict_async(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_operations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.ListOperationsResponse() - ) - response = await client.list_operations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_transport_close_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc" - ) - with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -@pytest.mark.asyncio -async def test_transport_close_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio" - ) - with mock.patch.object(type(getattr(client.transport, "_grpc_channel")), "close") as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_transport_close_rest(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest" - ) - with mock.patch.object(type(getattr(client.transport, "_session")), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - - -def test_client_ctx(): - transports = [ - 'rest', - 'grpc', - ] - for transport in transports: - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - -@pytest.mark.parametrize("client_class,transport_class", [ - (VideoStitcherServiceClient, transports.VideoStitcherServiceGrpcTransport), - (VideoStitcherServiceAsyncClient, transports.VideoStitcherServiceGrpcAsyncIOTransport), -]) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=mock_cred, - credentials_file=None, - host=client._DEFAULT_ENDPOINT_TEMPLATE.format(UNIVERSE_DOMAIN=client._DEFAULT_UNIVERSE), - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_metadata.json b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_metadata.json index 51d9ffec66d1..92a8e4a173a8 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_metadata.json +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/gapic_metadata.json @@ -316,6 +316,161 @@ ] } } + }, + "rest": { + "libraryClient": "VideoStitcherServiceClient", + "rpcs": { + "CreateCdnKey": { + "methods": [ + "create_cdn_key" + ] + }, + "CreateLiveConfig": { + "methods": [ + "create_live_config" + ] + }, + "CreateLiveSession": { + "methods": [ + "create_live_session" + ] + }, + "CreateSlate": { + "methods": [ + "create_slate" + ] + }, + "CreateVodConfig": { + "methods": [ + "create_vod_config" + ] + }, + "CreateVodSession": { + "methods": [ + "create_vod_session" + ] + }, + "DeleteCdnKey": { + "methods": [ + "delete_cdn_key" + ] + }, + "DeleteLiveConfig": { + "methods": [ + "delete_live_config" + ] + }, + "DeleteSlate": { + "methods": [ + "delete_slate" + ] + }, + "DeleteVodConfig": { + "methods": [ + "delete_vod_config" + ] + }, + "GetCdnKey": { + "methods": [ + "get_cdn_key" + ] + }, + "GetLiveAdTagDetail": { + "methods": [ + "get_live_ad_tag_detail" + ] + }, + "GetLiveConfig": { + "methods": [ + "get_live_config" + ] + }, + "GetLiveSession": { + "methods": [ + "get_live_session" + ] + }, + "GetSlate": { + "methods": [ + "get_slate" + ] + }, + "GetVodAdTagDetail": { + "methods": [ + "get_vod_ad_tag_detail" + ] + }, + "GetVodConfig": { + "methods": [ + "get_vod_config" + ] + }, + "GetVodSession": { + "methods": [ + "get_vod_session" + ] + }, + "GetVodStitchDetail": { + "methods": [ + "get_vod_stitch_detail" + ] + }, + "ListCdnKeys": { + "methods": [ + "list_cdn_keys" + ] + }, + "ListLiveAdTagDetails": { + "methods": [ + "list_live_ad_tag_details" + ] + }, + "ListLiveConfigs": { + "methods": [ + "list_live_configs" + ] + }, + "ListSlates": { + "methods": [ + "list_slates" + ] + }, + "ListVodAdTagDetails": { + "methods": [ + "list_vod_ad_tag_details" + ] + }, + "ListVodConfigs": { + "methods": [ + "list_vod_configs" + ] + }, + "ListVodStitchDetails": { + "methods": [ + "list_vod_stitch_details" + ] + }, + "UpdateCdnKey": { + "methods": [ + "update_cdn_key" + ] + }, + "UpdateLiveConfig": { + "methods": [ + "update_live_config" + ] + }, + "UpdateSlate": { + "methods": [ + "update_slate" + ] + }, + "UpdateVodConfig": { + "methods": [ + "update_vod_config" + ] + } + } } } } diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py index 8e528af94ec0..41f3a6dbe14b 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/client.py @@ -83,6 +83,7 @@ from .transports.base import DEFAULT_CLIENT_INFO, VideoStitcherServiceTransport from .transports.grpc import VideoStitcherServiceGrpcTransport from .transports.grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport +from .transports.rest import VideoStitcherServiceRestTransport class VideoStitcherServiceClientMeta(type): @@ -98,6 +99,7 @@ class VideoStitcherServiceClientMeta(type): ) # type: Dict[str, Type[VideoStitcherServiceTransport]] _transport_registry["grpc"] = VideoStitcherServiceGrpcTransport _transport_registry["grpc_asyncio"] = VideoStitcherServiceGrpcAsyncIOTransport + _transport_registry["rest"] = VideoStitcherServiceRestTransport def get_transport_class( cls, diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py index a54e61f317b5..90203be46261 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/__init__.py @@ -19,6 +19,7 @@ from .base import VideoStitcherServiceTransport from .grpc import VideoStitcherServiceGrpcTransport from .grpc_asyncio import VideoStitcherServiceGrpcAsyncIOTransport +from .rest import VideoStitcherServiceRestInterceptor, VideoStitcherServiceRestTransport # Compile a registry of transports. _transport_registry = ( @@ -26,9 +27,12 @@ ) # type: Dict[str, Type[VideoStitcherServiceTransport]] _transport_registry["grpc"] = VideoStitcherServiceGrpcTransport _transport_registry["grpc_asyncio"] = VideoStitcherServiceGrpcAsyncIOTransport +_transport_registry["rest"] = VideoStitcherServiceRestTransport __all__ = ( "VideoStitcherServiceTransport", "VideoStitcherServiceGrpcTransport", "VideoStitcherServiceGrpcAsyncIOTransport", + "VideoStitcherServiceRestTransport", + "VideoStitcherServiceRestInterceptor", ) diff --git a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py index 55831c29048c..9d93ccd186aa 100644 --- a/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2025 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,49 +13,59 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore -import re +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings -from google.api_core import gapic_v1, path_template, rest_helpers, rest_streaming +from google.api_core import gapic_v1, operations_v1, rest_helpers, rest_streaming from google.api_core import exceptions as core_exceptions from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.transport.requests import AuthorizedSession # type: ignore +from google.longrunning import operations_pb2 # type: ignore +import google.protobuf from google.protobuf import json_format -import grpc # type: ignore from requests import __version__ as requests_version -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - - -from google.protobuf import empty_pb2 # type: ignore - from google.cloud.video.stitcher_v1.types import ( ad_tag_details, cdn_keys, + live_configs, sessions, slates, stitch_details, video_stitcher_service, + vod_configs, ) from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO -from .base import VideoStitcherServiceTransport +from .rest_base import _BaseVideoStitcherServiceRestTransport + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object, None] # type: ignore + +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, grpc_version=None, - rest_version=requests_version, + rest_version=f"requests@{requests_version}", ) +if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER + DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__ + class VideoStitcherServiceRestInterceptor: """Interceptor for VideoStitcherService. @@ -80,6 +90,14 @@ def post_create_cdn_key(self, response): logging.log(f"Received response: {response}") return response + def pre_create_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_live_config(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_live_session(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -96,6 +114,14 @@ def post_create_slate(self, response): logging.log(f"Received response: {response}") return response + def pre_create_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + def pre_create_vod_session(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -108,10 +134,34 @@ def pre_delete_cdn_key(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def post_delete_cdn_key(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_live_config(self, response): + logging.log(f"Received response: {response}") + return response + def pre_delete_slate(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata + def post_delete_slate(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_delete_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_cdn_key(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -128,6 +178,14 @@ def post_get_live_ad_tag_detail(self, response): logging.log(f"Received response: {response}") return response + def pre_get_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_live_config(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_live_session(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -152,6 +210,14 @@ def post_get_vod_ad_tag_detail(self, response): logging.log(f"Received response: {response}") return response + def pre_get_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + def pre_get_vod_session(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -184,6 +250,14 @@ def post_list_live_ad_tag_details(self, response): logging.log(f"Received response: {response}") return response + def pre_list_live_configs(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_live_configs(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_slates(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -200,6 +274,14 @@ def post_list_vod_ad_tag_details(self, response): logging.log(f"Received response: {response}") return response + def pre_list_vod_configs(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_vod_configs(self, response): + logging.log(f"Received response: {response}") + return response + def pre_list_vod_stitch_details(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -216,6 +298,14 @@ def post_update_cdn_key(self, response): logging.log(f"Received response: {response}") return response + def pre_update_live_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_live_config(self, response): + logging.log(f"Received response: {response}") + return response + def pre_update_slate(self, request, metadata): logging.log(f"Received request: {request}") return request, metadata @@ -224,6 +314,14 @@ def post_update_slate(self, response): logging.log(f"Received response: {response}") return response + def pre_update_vod_config(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_vod_config(self, response): + logging.log(f"Received response: {response}") + return response + transport = VideoStitcherServiceRestTransport(interceptor=MyCustomVideoStitcherServiceInterceptor()) client = VideoStitcherServiceClient(transport=transport) @@ -233,8 +331,11 @@ def post_update_slate(self, response): def pre_create_cdn_key( self, request: video_stitcher_service.CreateCdnKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.CreateCdnKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.CreateCdnKeyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_cdn_key Override in a subclass to manipulate the request or metadata @@ -242,21 +343,96 @@ def pre_create_cdn_key( """ return request, metadata - def post_create_cdn_key(self, response: cdn_keys.CdnKey) -> cdn_keys.CdnKey: + def post_create_cdn_key( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for create_cdn_key - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_create_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_create_cdn_key` interceptor runs + before the `post_create_cdn_key_with_metadata` interceptor. + """ + return response + + def post_create_cdn_key_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_cdn_key_with_metadata` + interceptor in new development instead of the `post_create_cdn_key` interceptor. + When both interceptors are used, this `post_create_cdn_key_with_metadata` interceptor runs after the + `post_create_cdn_key` interceptor. The (possibly modified) response returned by + `post_create_cdn_key` will be passed to + `post_create_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_create_live_config( + self, + request: video_stitcher_service.CreateLiveConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.CreateLiveConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for create_live_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_live_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_live_config + + DEPRECATED. Please use the `post_create_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_live_config` interceptor runs + before the `post_create_live_config_with_metadata` interceptor. """ return response + def post_create_live_config_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_live_config_with_metadata` + interceptor in new development instead of the `post_create_live_config` interceptor. + When both interceptors are used, this `post_create_live_config_with_metadata` interceptor runs after the + `post_create_live_config` interceptor. The (possibly modified) response returned by + `post_create_live_config` will be passed to + `post_create_live_config_with_metadata`. + """ + return response, metadata + def pre_create_live_session( self, request: video_stitcher_service.CreateLiveSessionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.CreateLiveSessionRequest, Sequence[Tuple[str, str]] + video_stitcher_service.CreateLiveSessionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_live_session @@ -270,17 +446,43 @@ def post_create_live_session( ) -> sessions.LiveSession: """Post-rpc interceptor for create_live_session - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_create_live_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_create_live_session` interceptor runs + before the `post_create_live_session_with_metadata` interceptor. """ return response + def post_create_live_session_with_metadata( + self, + response: sessions.LiveSession, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[sessions.LiveSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_live_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_live_session_with_metadata` + interceptor in new development instead of the `post_create_live_session` interceptor. + When both interceptors are used, this `post_create_live_session_with_metadata` interceptor runs after the + `post_create_live_session` interceptor. The (possibly modified) response returned by + `post_create_live_session` will be passed to + `post_create_live_session_with_metadata`. + """ + return response, metadata + def pre_create_slate( self, request: video_stitcher_service.CreateSlateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.CreateSlateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.CreateSlateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_slate Override in a subclass to manipulate the request or metadata @@ -288,21 +490,96 @@ def pre_create_slate( """ return request, metadata - def post_create_slate(self, response: slates.Slate) -> slates.Slate: + def post_create_slate( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for create_slate - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_create_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_create_slate` interceptor runs + before the `post_create_slate_with_metadata` interceptor. + """ + return response + + def post_create_slate_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_slate + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_slate_with_metadata` + interceptor in new development instead of the `post_create_slate` interceptor. + When both interceptors are used, this `post_create_slate_with_metadata` interceptor runs after the + `post_create_slate` interceptor. The (possibly modified) response returned by + `post_create_slate` will be passed to + `post_create_slate_with_metadata`. + """ + return response, metadata + + def pre_create_vod_config( + self, + request: video_stitcher_service.CreateVodConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.CreateVodConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for create_vod_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_create_vod_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for create_vod_config + + DEPRECATED. Please use the `post_create_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_create_vod_config` interceptor runs + before the `post_create_vod_config_with_metadata` interceptor. """ return response + def post_create_vod_config_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_vod_config_with_metadata` + interceptor in new development instead of the `post_create_vod_config` interceptor. + When both interceptors are used, this `post_create_vod_config_with_metadata` interceptor runs after the + `post_create_vod_config` interceptor. The (possibly modified) response returned by + `post_create_vod_config` will be passed to + `post_create_vod_config_with_metadata`. + """ + return response, metadata + def pre_create_vod_session( self, request: video_stitcher_service.CreateVodSessionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.CreateVodSessionRequest, Sequence[Tuple[str, str]] + video_stitcher_service.CreateVodSessionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_vod_session @@ -316,17 +593,43 @@ def post_create_vod_session( ) -> sessions.VodSession: """Post-rpc interceptor for create_vod_session - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_create_vod_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_create_vod_session` interceptor runs + before the `post_create_vod_session_with_metadata` interceptor. """ return response + def post_create_vod_session_with_metadata( + self, + response: sessions.VodSession, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[sessions.VodSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for create_vod_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_create_vod_session_with_metadata` + interceptor in new development instead of the `post_create_vod_session` interceptor. + When both interceptors are used, this `post_create_vod_session_with_metadata` interceptor runs after the + `post_create_vod_session` interceptor. The (possibly modified) response returned by + `post_create_vod_session` will be passed to + `post_create_vod_session_with_metadata`. + """ + return response, metadata + def pre_delete_cdn_key( self, request: video_stitcher_service.DeleteCdnKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.DeleteCdnKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.DeleteCdnKeyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_cdn_key Override in a subclass to manipulate the request or metadata @@ -334,139 +637,531 @@ def pre_delete_cdn_key( """ return request, metadata - def pre_delete_slate( - self, - request: video_stitcher_service.DeleteSlateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.DeleteSlateRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_slate + def post_delete_cdn_key( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_cdn_key - Override in a subclass to manipulate the request or metadata - before they are sent to the VideoStitcherService server. + DEPRECATED. Please use the `post_delete_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_delete_cdn_key` interceptor runs + before the `post_delete_cdn_key_with_metadata` interceptor. """ - return request, metadata + return response - def pre_get_cdn_key( + def post_delete_cdn_key_with_metadata( self, - request: video_stitcher_service.GetCdnKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.GetCdnKeyRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_cdn_key + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_cdn_key_with_metadata` + interceptor in new development instead of the `post_delete_cdn_key` interceptor. + When both interceptors are used, this `post_delete_cdn_key_with_metadata` interceptor runs after the + `post_delete_cdn_key` interceptor. The (possibly modified) response returned by + `post_delete_cdn_key` will be passed to + `post_delete_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_delete_live_config( + self, + request: video_stitcher_service.DeleteLiveConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.DeleteLiveConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for delete_live_config Override in a subclass to manipulate the request or metadata before they are sent to the VideoStitcherService server. """ return request, metadata - def post_get_cdn_key(self, response: cdn_keys.CdnKey) -> cdn_keys.CdnKey: - """Post-rpc interceptor for get_cdn_key + def post_delete_live_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_live_config - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_delete_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_delete_live_config` interceptor runs + before the `post_delete_live_config_with_metadata` interceptor. """ return response - def pre_get_live_ad_tag_detail( + def post_delete_live_config_with_metadata( self, - request: video_stitcher_service.GetLiveAdTagDetailRequest, - metadata: Sequence[Tuple[str, str]], + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_live_config_with_metadata` + interceptor in new development instead of the `post_delete_live_config` interceptor. + When both interceptors are used, this `post_delete_live_config_with_metadata` interceptor runs after the + `post_delete_live_config` interceptor. The (possibly modified) response returned by + `post_delete_live_config` will be passed to + `post_delete_live_config_with_metadata`. + """ + return response, metadata + + def pre_delete_slate( + self, + request: video_stitcher_service.DeleteSlateRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.GetLiveAdTagDetailRequest, Sequence[Tuple[str, str]] + video_stitcher_service.DeleteSlateRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_live_ad_tag_detail + """Pre-rpc interceptor for delete_slate Override in a subclass to manipulate the request or metadata before they are sent to the VideoStitcherService server. """ return request, metadata - def post_get_live_ad_tag_detail( - self, response: ad_tag_details.LiveAdTagDetail - ) -> ad_tag_details.LiveAdTagDetail: - """Post-rpc interceptor for get_live_ad_tag_detail + def post_delete_slate( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_slate - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_delete_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_delete_slate` interceptor runs + before the `post_delete_slate_with_metadata` interceptor. """ return response - def pre_get_live_session( + def post_delete_slate_with_metadata( self, - request: video_stitcher_service.GetLiveSessionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.GetLiveSessionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_live_session + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_slate + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_slate_with_metadata` + interceptor in new development instead of the `post_delete_slate` interceptor. + When both interceptors are used, this `post_delete_slate_with_metadata` interceptor runs after the + `post_delete_slate` interceptor. The (possibly modified) response returned by + `post_delete_slate` will be passed to + `post_delete_slate_with_metadata`. + """ + return response, metadata + + def pre_delete_vod_config( + self, + request: video_stitcher_service.DeleteVodConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.DeleteVodConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for delete_vod_config Override in a subclass to manipulate the request or metadata before they are sent to the VideoStitcherService server. """ return request, metadata - def post_get_live_session( - self, response: sessions.LiveSession - ) -> sessions.LiveSession: - """Post-rpc interceptor for get_live_session + def post_delete_vod_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for delete_vod_config - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_delete_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_delete_vod_config` interceptor runs + before the `post_delete_vod_config_with_metadata` interceptor. """ return response - def pre_get_slate( + def post_delete_vod_config_with_metadata( self, - request: video_stitcher_service.GetSlateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.GetSlateRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_slate + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for delete_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_delete_vod_config_with_metadata` + interceptor in new development instead of the `post_delete_vod_config` interceptor. + When both interceptors are used, this `post_delete_vod_config_with_metadata` interceptor runs after the + `post_delete_vod_config` interceptor. The (possibly modified) response returned by + `post_delete_vod_config` will be passed to + `post_delete_vod_config_with_metadata`. + """ + return response, metadata + + def pre_get_cdn_key( + self, + request: video_stitcher_service.GetCdnKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.GetCdnKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_cdn_key Override in a subclass to manipulate the request or metadata before they are sent to the VideoStitcherService server. """ return request, metadata - def post_get_slate(self, response: slates.Slate) -> slates.Slate: - """Post-rpc interceptor for get_slate + def post_get_cdn_key(self, response: cdn_keys.CdnKey) -> cdn_keys.CdnKey: + """Post-rpc interceptor for get_cdn_key - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_get_cdn_key` interceptor runs + before the `post_get_cdn_key_with_metadata` interceptor. """ return response - def pre_get_vod_ad_tag_detail( + def post_get_cdn_key_with_metadata( self, - request: video_stitcher_service.GetVodAdTagDetailRequest, - metadata: Sequence[Tuple[str, str]], + response: cdn_keys.CdnKey, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cdn_keys.CdnKey, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_cdn_key_with_metadata` + interceptor in new development instead of the `post_get_cdn_key` interceptor. + When both interceptors are used, this `post_get_cdn_key_with_metadata` interceptor runs after the + `post_get_cdn_key` interceptor. The (possibly modified) response returned by + `post_get_cdn_key` will be passed to + `post_get_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_get_live_ad_tag_detail( + self, + request: video_stitcher_service.GetLiveAdTagDetailRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.GetVodAdTagDetailRequest, Sequence[Tuple[str, str]] + video_stitcher_service.GetLiveAdTagDetailRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: - """Pre-rpc interceptor for get_vod_ad_tag_detail + """Pre-rpc interceptor for get_live_ad_tag_detail Override in a subclass to manipulate the request or metadata before they are sent to the VideoStitcherService server. """ return request, metadata - def post_get_vod_ad_tag_detail( - self, response: ad_tag_details.VodAdTagDetail - ) -> ad_tag_details.VodAdTagDetail: - """Post-rpc interceptor for get_vod_ad_tag_detail + def post_get_live_ad_tag_detail( + self, response: ad_tag_details.LiveAdTagDetail + ) -> ad_tag_details.LiveAdTagDetail: + """Post-rpc interceptor for get_live_ad_tag_detail - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_live_ad_tag_detail_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_get_live_ad_tag_detail` interceptor runs + before the `post_get_live_ad_tag_detail_with_metadata` interceptor. """ return response - def pre_get_vod_session( + def post_get_live_ad_tag_detail_with_metadata( self, - request: video_stitcher_service.GetVodSessionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.GetVodSessionRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_vod_session + response: ad_tag_details.LiveAdTagDetail, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ad_tag_details.LiveAdTagDetail, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_live_ad_tag_detail + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_live_ad_tag_detail_with_metadata` + interceptor in new development instead of the `post_get_live_ad_tag_detail` interceptor. + When both interceptors are used, this `post_get_live_ad_tag_detail_with_metadata` interceptor runs after the + `post_get_live_ad_tag_detail` interceptor. The (possibly modified) response returned by + `post_get_live_ad_tag_detail` will be passed to + `post_get_live_ad_tag_detail_with_metadata`. + """ + return response, metadata + + def pre_get_live_config( + self, + request: video_stitcher_service.GetLiveConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.GetLiveConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_live_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_live_config( + self, response: live_configs.LiveConfig + ) -> live_configs.LiveConfig: + """Post-rpc interceptor for get_live_config + + DEPRECATED. Please use the `post_get_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_live_config` interceptor runs + before the `post_get_live_config_with_metadata` interceptor. + """ + return response + + def post_get_live_config_with_metadata( + self, + response: live_configs.LiveConfig, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[live_configs.LiveConfig, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_live_config_with_metadata` + interceptor in new development instead of the `post_get_live_config` interceptor. + When both interceptors are used, this `post_get_live_config_with_metadata` interceptor runs after the + `post_get_live_config` interceptor. The (possibly modified) response returned by + `post_get_live_config` will be passed to + `post_get_live_config_with_metadata`. + """ + return response, metadata + + def pre_get_live_session( + self, + request: video_stitcher_service.GetLiveSessionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.GetLiveSessionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_live_session + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_live_session( + self, response: sessions.LiveSession + ) -> sessions.LiveSession: + """Post-rpc interceptor for get_live_session + + DEPRECATED. Please use the `post_get_live_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_live_session` interceptor runs + before the `post_get_live_session_with_metadata` interceptor. + """ + return response + + def post_get_live_session_with_metadata( + self, + response: sessions.LiveSession, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[sessions.LiveSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_live_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_live_session_with_metadata` + interceptor in new development instead of the `post_get_live_session` interceptor. + When both interceptors are used, this `post_get_live_session_with_metadata` interceptor runs after the + `post_get_live_session` interceptor. The (possibly modified) response returned by + `post_get_live_session` will be passed to + `post_get_live_session_with_metadata`. + """ + return response, metadata + + def pre_get_slate( + self, + request: video_stitcher_service.GetSlateRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.GetSlateRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_slate + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_slate(self, response: slates.Slate) -> slates.Slate: + """Post-rpc interceptor for get_slate + + DEPRECATED. Please use the `post_get_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_slate` interceptor runs + before the `post_get_slate_with_metadata` interceptor. + """ + return response + + def post_get_slate_with_metadata( + self, response: slates.Slate, metadata: Sequence[Tuple[str, Union[str, bytes]]] + ) -> Tuple[slates.Slate, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_slate + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_slate_with_metadata` + interceptor in new development instead of the `post_get_slate` interceptor. + When both interceptors are used, this `post_get_slate_with_metadata` interceptor runs after the + `post_get_slate` interceptor. The (possibly modified) response returned by + `post_get_slate` will be passed to + `post_get_slate_with_metadata`. + """ + return response, metadata + + def pre_get_vod_ad_tag_detail( + self, + request: video_stitcher_service.GetVodAdTagDetailRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.GetVodAdTagDetailRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_vod_ad_tag_detail + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_vod_ad_tag_detail( + self, response: ad_tag_details.VodAdTagDetail + ) -> ad_tag_details.VodAdTagDetail: + """Post-rpc interceptor for get_vod_ad_tag_detail + + DEPRECATED. Please use the `post_get_vod_ad_tag_detail_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_vod_ad_tag_detail` interceptor runs + before the `post_get_vod_ad_tag_detail_with_metadata` interceptor. + """ + return response + + def post_get_vod_ad_tag_detail_with_metadata( + self, + response: ad_tag_details.VodAdTagDetail, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ad_tag_details.VodAdTagDetail, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_ad_tag_detail + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_ad_tag_detail_with_metadata` + interceptor in new development instead of the `post_get_vod_ad_tag_detail` interceptor. + When both interceptors are used, this `post_get_vod_ad_tag_detail_with_metadata` interceptor runs after the + `post_get_vod_ad_tag_detail` interceptor. The (possibly modified) response returned by + `post_get_vod_ad_tag_detail` will be passed to + `post_get_vod_ad_tag_detail_with_metadata`. + """ + return response, metadata + + def pre_get_vod_config( + self, + request: video_stitcher_service.GetVodConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.GetVodConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_vod_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_get_vod_config( + self, response: vod_configs.VodConfig + ) -> vod_configs.VodConfig: + """Post-rpc interceptor for get_vod_config + + DEPRECATED. Please use the `post_get_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_get_vod_config` interceptor runs + before the `post_get_vod_config_with_metadata` interceptor. + """ + return response + + def post_get_vod_config_with_metadata( + self, + response: vod_configs.VodConfig, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[vod_configs.VodConfig, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_config_with_metadata` + interceptor in new development instead of the `post_get_vod_config` interceptor. + When both interceptors are used, this `post_get_vod_config_with_metadata` interceptor runs after the + `post_get_vod_config` interceptor. The (possibly modified) response returned by + `post_get_vod_config` will be passed to + `post_get_vod_config_with_metadata`. + """ + return response, metadata + + def pre_get_vod_session( + self, + request: video_stitcher_service.GetVodSessionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.GetVodSessionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for get_vod_session Override in a subclass to manipulate the request or metadata before they are sent to the VideoStitcherService server. @@ -478,18 +1173,42 @@ def post_get_vod_session( ) -> sessions.VodSession: """Post-rpc interceptor for get_vod_session - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_vod_session_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_get_vod_session` interceptor runs + before the `post_get_vod_session_with_metadata` interceptor. """ return response + def post_get_vod_session_with_metadata( + self, + response: sessions.VodSession, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[sessions.VodSession, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_session + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_session_with_metadata` + interceptor in new development instead of the `post_get_vod_session` interceptor. + When both interceptors are used, this `post_get_vod_session_with_metadata` interceptor runs after the + `post_get_vod_session` interceptor. The (possibly modified) response returned by + `post_get_vod_session` will be passed to + `post_get_vod_session_with_metadata`. + """ + return response, metadata + def pre_get_vod_stitch_detail( self, request: video_stitcher_service.GetVodStitchDetailRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.GetVodStitchDetailRequest, Sequence[Tuple[str, str]] + video_stitcher_service.GetVodStitchDetailRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_vod_stitch_detail @@ -503,17 +1222,43 @@ def post_get_vod_stitch_detail( ) -> stitch_details.VodStitchDetail: """Post-rpc interceptor for get_vod_stitch_detail - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_get_vod_stitch_detail_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_get_vod_stitch_detail` interceptor runs + before the `post_get_vod_stitch_detail_with_metadata` interceptor. """ return response + def post_get_vod_stitch_detail_with_metadata( + self, + response: stitch_details.VodStitchDetail, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[stitch_details.VodStitchDetail, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for get_vod_stitch_detail + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_get_vod_stitch_detail_with_metadata` + interceptor in new development instead of the `post_get_vod_stitch_detail` interceptor. + When both interceptors are used, this `post_get_vod_stitch_detail_with_metadata` interceptor runs after the + `post_get_vod_stitch_detail` interceptor. The (possibly modified) response returned by + `post_get_vod_stitch_detail` will be passed to + `post_get_vod_stitch_detail_with_metadata`. + """ + return response, metadata + def pre_list_cdn_keys( self, request: video_stitcher_service.ListCdnKeysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.ListCdnKeysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListCdnKeysRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_cdn_keys Override in a subclass to manipulate the request or metadata @@ -526,18 +1271,45 @@ def post_list_cdn_keys( ) -> video_stitcher_service.ListCdnKeysResponse: """Post-rpc interceptor for list_cdn_keys - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_list_cdn_keys_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_list_cdn_keys` interceptor runs + before the `post_list_cdn_keys_with_metadata` interceptor. """ return response + def post_list_cdn_keys_with_metadata( + self, + response: video_stitcher_service.ListCdnKeysResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListCdnKeysResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_cdn_keys + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_cdn_keys_with_metadata` + interceptor in new development instead of the `post_list_cdn_keys` interceptor. + When both interceptors are used, this `post_list_cdn_keys_with_metadata` interceptor runs after the + `post_list_cdn_keys` interceptor. The (possibly modified) response returned by + `post_list_cdn_keys` will be passed to + `post_list_cdn_keys_with_metadata`. + """ + return response, metadata + def pre_list_live_ad_tag_details( self, request: video_stitcher_service.ListLiveAdTagDetailsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.ListLiveAdTagDetailsRequest, Sequence[Tuple[str, str]] + video_stitcher_service.ListLiveAdTagDetailsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_live_ad_tag_details @@ -551,17 +1323,98 @@ def post_list_live_ad_tag_details( ) -> video_stitcher_service.ListLiveAdTagDetailsResponse: """Post-rpc interceptor for list_live_ad_tag_details - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_list_live_ad_tag_details_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_list_live_ad_tag_details` interceptor runs + before the `post_list_live_ad_tag_details_with_metadata` interceptor. + """ + return response + + def post_list_live_ad_tag_details_with_metadata( + self, + response: video_stitcher_service.ListLiveAdTagDetailsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListLiveAdTagDetailsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_live_ad_tag_details + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_live_ad_tag_details_with_metadata` + interceptor in new development instead of the `post_list_live_ad_tag_details` interceptor. + When both interceptors are used, this `post_list_live_ad_tag_details_with_metadata` interceptor runs after the + `post_list_live_ad_tag_details` interceptor. The (possibly modified) response returned by + `post_list_live_ad_tag_details` will be passed to + `post_list_live_ad_tag_details_with_metadata`. + """ + return response, metadata + + def pre_list_live_configs( + self, + request: video_stitcher_service.ListLiveConfigsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListLiveConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_live_configs + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_live_configs( + self, response: video_stitcher_service.ListLiveConfigsResponse + ) -> video_stitcher_service.ListLiveConfigsResponse: + """Post-rpc interceptor for list_live_configs + + DEPRECATED. Please use the `post_list_live_configs_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_live_configs` interceptor runs + before the `post_list_live_configs_with_metadata` interceptor. """ return response + def post_list_live_configs_with_metadata( + self, + response: video_stitcher_service.ListLiveConfigsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListLiveConfigsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_live_configs + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_live_configs_with_metadata` + interceptor in new development instead of the `post_list_live_configs` interceptor. + When both interceptors are used, this `post_list_live_configs_with_metadata` interceptor runs after the + `post_list_live_configs` interceptor. The (possibly modified) response returned by + `post_list_live_configs` will be passed to + `post_list_live_configs_with_metadata`. + """ + return response, metadata + def pre_list_slates( self, request: video_stitcher_service.ListSlatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.ListSlatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListSlatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_slates Override in a subclass to manipulate the request or metadata @@ -574,18 +1427,45 @@ def post_list_slates( ) -> video_stitcher_service.ListSlatesResponse: """Post-rpc interceptor for list_slates - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_list_slates_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_list_slates` interceptor runs + before the `post_list_slates_with_metadata` interceptor. """ return response + def post_list_slates_with_metadata( + self, + response: video_stitcher_service.ListSlatesResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListSlatesResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_slates + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_slates_with_metadata` + interceptor in new development instead of the `post_list_slates` interceptor. + When both interceptors are used, this `post_list_slates_with_metadata` interceptor runs after the + `post_list_slates` interceptor. The (possibly modified) response returned by + `post_list_slates` will be passed to + `post_list_slates_with_metadata`. + """ + return response, metadata + def pre_list_vod_ad_tag_details( self, request: video_stitcher_service.ListVodAdTagDetailsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.ListVodAdTagDetailsRequest, Sequence[Tuple[str, str]] + video_stitcher_service.ListVodAdTagDetailsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_vod_ad_tag_details @@ -599,18 +1479,97 @@ def post_list_vod_ad_tag_details( ) -> video_stitcher_service.ListVodAdTagDetailsResponse: """Post-rpc interceptor for list_vod_ad_tag_details - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_list_vod_ad_tag_details_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_list_vod_ad_tag_details` interceptor runs + before the `post_list_vod_ad_tag_details_with_metadata` interceptor. + """ + return response + + def post_list_vod_ad_tag_details_with_metadata( + self, + response: video_stitcher_service.ListVodAdTagDetailsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListVodAdTagDetailsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_vod_ad_tag_details + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_vod_ad_tag_details_with_metadata` + interceptor in new development instead of the `post_list_vod_ad_tag_details` interceptor. + When both interceptors are used, this `post_list_vod_ad_tag_details_with_metadata` interceptor runs after the + `post_list_vod_ad_tag_details` interceptor. The (possibly modified) response returned by + `post_list_vod_ad_tag_details` will be passed to + `post_list_vod_ad_tag_details_with_metadata`. + """ + return response, metadata + + def pre_list_vod_configs( + self, + request: video_stitcher_service.ListVodConfigsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListVodConfigsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for list_vod_configs + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_list_vod_configs( + self, response: video_stitcher_service.ListVodConfigsResponse + ) -> video_stitcher_service.ListVodConfigsResponse: + """Post-rpc interceptor for list_vod_configs + + DEPRECATED. Please use the `post_list_vod_configs_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_list_vod_configs` interceptor runs + before the `post_list_vod_configs_with_metadata` interceptor. """ return response + def post_list_vod_configs_with_metadata( + self, + response: video_stitcher_service.ListVodConfigsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListVodConfigsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_vod_configs + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_vod_configs_with_metadata` + interceptor in new development instead of the `post_list_vod_configs` interceptor. + When both interceptors are used, this `post_list_vod_configs_with_metadata` interceptor runs after the + `post_list_vod_configs` interceptor. The (possibly modified) response returned by + `post_list_vod_configs` will be passed to + `post_list_vod_configs_with_metadata`. + """ + return response, metadata + def pre_list_vod_stitch_details( self, request: video_stitcher_service.ListVodStitchDetailsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - video_stitcher_service.ListVodStitchDetailsRequest, Sequence[Tuple[str, str]] + video_stitcher_service.ListVodStitchDetailsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_vod_stitch_details @@ -624,17 +1583,46 @@ def post_list_vod_stitch_details( ) -> video_stitcher_service.ListVodStitchDetailsResponse: """Post-rpc interceptor for list_vod_stitch_details - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_list_vod_stitch_details_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_list_vod_stitch_details` interceptor runs + before the `post_list_vod_stitch_details_with_metadata` interceptor. """ return response + def post_list_vod_stitch_details_with_metadata( + self, + response: video_stitcher_service.ListVodStitchDetailsResponse, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.ListVodStitchDetailsResponse, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Post-rpc interceptor for list_vod_stitch_details + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_list_vod_stitch_details_with_metadata` + interceptor in new development instead of the `post_list_vod_stitch_details` interceptor. + When both interceptors are used, this `post_list_vod_stitch_details_with_metadata` interceptor runs after the + `post_list_vod_stitch_details` interceptor. The (possibly modified) response returned by + `post_list_vod_stitch_details` will be passed to + `post_list_vod_stitch_details_with_metadata`. + """ + return response, metadata + def pre_update_cdn_key( self, request: video_stitcher_service.UpdateCdnKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.UpdateCdnKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.UpdateCdnKeyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_cdn_key Override in a subclass to manipulate the request or metadata @@ -642,20 +1630,97 @@ def pre_update_cdn_key( """ return request, metadata - def post_update_cdn_key(self, response: cdn_keys.CdnKey) -> cdn_keys.CdnKey: + def post_update_cdn_key( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: """Post-rpc interceptor for update_cdn_key - Override in a subclass to manipulate the response + DEPRECATED. Please use the `post_update_cdn_key_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response after it is returned by the VideoStitcherService server but before - it is returned to user code. + it is returned to user code. This `post_update_cdn_key` interceptor runs + before the `post_update_cdn_key_with_metadata` interceptor. + """ + return response + + def post_update_cdn_key_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_cdn_key + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_cdn_key_with_metadata` + interceptor in new development instead of the `post_update_cdn_key` interceptor. + When both interceptors are used, this `post_update_cdn_key_with_metadata` interceptor runs after the + `post_update_cdn_key` interceptor. The (possibly modified) response returned by + `post_update_cdn_key` will be passed to + `post_update_cdn_key_with_metadata`. + """ + return response, metadata + + def pre_update_live_config( + self, + request: video_stitcher_service.UpdateLiveConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.UpdateLiveConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_live_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_update_live_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_live_config + + DEPRECATED. Please use the `post_update_live_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_update_live_config` interceptor runs + before the `post_update_live_config_with_metadata` interceptor. """ return response + def post_update_live_config_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_live_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_live_config_with_metadata` + interceptor in new development instead of the `post_update_live_config` interceptor. + When both interceptors are used, this `post_update_live_config_with_metadata` interceptor runs after the + `post_update_live_config` interceptor. The (possibly modified) response returned by + `post_update_live_config` will be passed to + `post_update_live_config_with_metadata`. + """ + return response, metadata + def pre_update_slate( self, request: video_stitcher_service.UpdateSlateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[video_stitcher_service.UpdateSlateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.UpdateSlateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_slate Override in a subclass to manipulate the request or metadata @@ -663,9 +1728,179 @@ def pre_update_slate( """ return request, metadata - def post_update_slate(self, response: slates.Slate) -> slates.Slate: + def post_update_slate( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_slate + + DEPRECATED. Please use the `post_update_slate_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_update_slate` interceptor runs + before the `post_update_slate_with_metadata` interceptor. + """ + return response + + def post_update_slate_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: """Post-rpc interceptor for update_slate + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_slate_with_metadata` + interceptor in new development instead of the `post_update_slate` interceptor. + When both interceptors are used, this `post_update_slate_with_metadata` interceptor runs after the + `post_update_slate` interceptor. The (possibly modified) response returned by + `post_update_slate` will be passed to + `post_update_slate_with_metadata`. + """ + return response, metadata + + def pre_update_vod_config( + self, + request: video_stitcher_service.UpdateVodConfigRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + video_stitcher_service.UpdateVodConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: + """Pre-rpc interceptor for update_vod_config + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_update_vod_config( + self, response: operations_pb2.Operation + ) -> operations_pb2.Operation: + """Post-rpc interceptor for update_vod_config + + DEPRECATED. Please use the `post_update_vod_config_with_metadata` + interceptor instead. + + Override in a subclass to read or manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. This `post_update_vod_config` interceptor runs + before the `post_update_vod_config_with_metadata` interceptor. + """ + return response + + def post_update_vod_config_with_metadata( + self, + response: operations_pb2.Operation, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]: + """Post-rpc interceptor for update_vod_config + + Override in a subclass to read or manipulate the response or metadata after it + is returned by the VideoStitcherService server but before it is returned to user code. + + We recommend only using this `post_update_vod_config_with_metadata` + interceptor in new development instead of the `post_update_vod_config` interceptor. + When both interceptors are used, this `post_update_vod_config_with_metadata` interceptor runs after the + `post_update_vod_config` interceptor. The (possibly modified) response returned by + `post_update_vod_config` will be passed to + `post_update_vod_config_with_metadata`. + """ + return response, metadata + + def pre_cancel_operation( + self, + request: operations_pb2.CancelOperationRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for cancel_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService 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 VideoStitcherService server but before + it is returned to user code. + """ + return response + + def pre_delete_operation( + self, + request: operations_pb2.DeleteOperationRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.DeleteOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for delete_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService server. + """ + return request, metadata + + def post_delete_operation(self, response: None) -> None: + """Post-rpc interceptor for delete_operation + + Override in a subclass to manipulate the response + after it is returned by the VideoStitcherService server but before + it is returned to user code. + """ + return response + + def pre_get_operation( + self, + request: operations_pb2.GetOperationRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for get_operation + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService 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 VideoStitcherService server but before + it is returned to user code. + """ + return response + + def pre_list_operations( + self, + request: operations_pb2.ListOperationsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: + """Pre-rpc interceptor for list_operations + + Override in a subclass to manipulate the request or metadata + before they are sent to the VideoStitcherService 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 VideoStitcherService server but before it is returned to user code. @@ -680,8 +1915,8 @@ class VideoStitcherServiceRestStub: _interceptor: VideoStitcherServiceRestInterceptor -class VideoStitcherServiceRestTransport(VideoStitcherServiceTransport): - """REST backend transport for VideoStitcherService. +class VideoStitcherServiceRestTransport(_BaseVideoStitcherServiceRestTransport): + """REST backend synchronous transport for VideoStitcherService. Video-On-Demand content stitching API allows you to insert ads into (VoD) video on demand files. You will be able to render @@ -694,7 +1929,6 @@ class VideoStitcherServiceRestTransport(VideoStitcherServiceTransport): and call it. It sends JSON representations of protocol buffers over HTTP/1.1 - """ def __init__( @@ -716,99 +1950,1689 @@ def __init__( Args: host (Optional[str]): - The hostname to connect to. + The hostname to connect to (default: 'videostitcher.googleapis.com'). 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 + 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 + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + url_scheme=url_scheme, + 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 VideoStitcherServiceRestInterceptor() + self._prep_wrapped_messages(client_info) + + @property + def operations_client(self) -> operations_v1.AbstractOperationsClient: + """Create the client designed to process long-running operations. + + This property caches on the instance; repeated calls return the same + client. + """ + # Only create a new client if we do not already have one. + if self._operations_client is None: + http_options: Dict[str, List[Dict[str, str]]] = { + "google.longrunning.Operations.CancelOperation": [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel", + "body": "*", + }, + ], + "google.longrunning.Operations.DeleteOperation": [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, + ], + "google.longrunning.Operations.GetOperation": [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, + ], + "google.longrunning.Operations.ListOperations": [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*}/operations", + }, + ], + } + + rest_transport = operations_v1.OperationsRestTransport( + host=self._host, + # use the credentials which are saved + credentials=self._credentials, + scopes=self._scopes, + http_options=http_options, + path_prefix="v1", + ) + + self._operations_client = operations_v1.AbstractOperationsClient( + transport=rest_transport + ) + + # Return the client from cache. + return self._operations_client + + class _CreateCdnKey( + _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: video_stitcher_service.CreateCdnKeyRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create cdn key method over HTTP. + + Args: + request (~.video_stitcher_service.CreateCdnKeyRequest): + The request object. Request message for + VideoStitcherService.createCdnKey. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateCdnKey", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateCdnKey._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + 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_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_cdn_key_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_cdn_key", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateLiveConfig( + _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: video_stitcher_service.CreateLiveConfigRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create live config method over HTTP. + + Args: + request (~.video_stitcher_service.CreateLiveConfigRequest): + The request object. Request message for + VideoStitcherService.createLiveConfig + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_live_config( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateLiveConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + VideoStitcherServiceRestTransport._CreateLiveConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + 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_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_live_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateLiveSession( + _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateLiveSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: video_stitcher_service.CreateLiveSessionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.LiveSession: + r"""Call the create live session method over HTTP. + + Args: + request (~.video_stitcher_service.CreateLiveSessionRequest): + The request object. Request message for + VideoStitcherService.createLiveSession. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.sessions.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_live_session( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateLiveSession", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + VideoStitcherServiceRestTransport._CreateLiveSession._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + 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 = sessions.LiveSession() + pb_resp = sessions.LiveSession.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_live_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_live_session_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = sessions.LiveSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_live_session", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateLiveSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateSlate( + _BaseVideoStitcherServiceRestTransport._BaseCreateSlate, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: video_stitcher_service.CreateSlateRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create slate method over HTTP. + + Args: + request (~.video_stitcher_service.CreateSlateRequest): + The request object. Request message for + VideoStitcherService.createSlate. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateSlate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateSlate._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + 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_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_slate_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_slate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateVodConfig( + _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: video_stitcher_service.CreateVodConfigRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the create vod config method over HTTP. + + Args: + request (~.video_stitcher_service.CreateVodConfigRequest): + The request object. Request message for + VideoStitcherService.createVodConfig + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_vod_config( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateVodConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CreateVodConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + 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_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_vod_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _CreateVodSession( + _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CreateVodSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: video_stitcher_service.CreateVodSessionRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.VodSession: + r"""Call the create vod session method over HTTP. + + Args: + request (~.video_stitcher_service.CreateVodSessionRequest): + The request object. Request message for + VideoStitcherService.createVodSession + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.sessions.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_http_options() + ) + + request, metadata = self._interceptor.pre_create_vod_session( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CreateVodSession", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + VideoStitcherServiceRestTransport._CreateVodSession._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + 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 = sessions.VodSession() + pb_resp = sessions.VodSession.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_create_vod_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_create_vod_session_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = sessions.VodSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.create_vod_session", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CreateVodSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteCdnKey( + _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: video_stitcher_service.DeleteCdnKeyRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete cdn key method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteCdnKeyRequest): + The request object. Request message for + VideoStitcherService.deleteCdnKey. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteCdnKey", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteCdnKey._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_cdn_key_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_cdn_key", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteLiveConfig( + _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: video_stitcher_service.DeleteLiveConfigRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete live config method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteLiveConfigRequest): + The request object. Request message for + VideoStitcherService.deleteLiveConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_live_config( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteLiveConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = ( + VideoStitcherServiceRestTransport._DeleteLiveConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_live_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_live_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteSlate( + _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: video_stitcher_service.DeleteSlateRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete slate method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteSlateRequest): + The request object. Request message for + VideoStitcherService.deleteSlate. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteSlate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteSlate._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) + + resp = self._interceptor.post_delete_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_slate_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_slate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _DeleteVodConfig( + _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: video_stitcher_service.DeleteVodConfigRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the delete vod config method over HTTP. + + Args: + request (~.video_stitcher_service.DeleteVodConfigRequest): + The request object. Request message for + VideoStitcherService.deleteVodConfig. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.operations_pb2.Operation: + This resource represents a + long-running operation that is the + result of a network API call. + + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_vod_config( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteVodConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteVodConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) - url_match_items = maybe_url_match.groupdict() + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) - host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host + # Return the response + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - 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 VideoStitcherServiceRestInterceptor() - self._prep_wrapped_messages(client_info) + resp = self._interceptor.post_delete_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_delete_vod_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.delete_vod_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp - class _CreateCdnKey(VideoStitcherServiceRestStub): + class _GetCdnKey( + _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("CreateCdnKey") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "cdnKeyId": "", - } - - @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 - } + return hash("VideoStitcherServiceRestTransport.GetCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.CreateCdnKeyRequest, + request: video_stitcher_service.GetCdnKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cdn_keys.CdnKey: - r"""Call the create cdn key method over HTTP. + r"""Call the get cdn key method over HTTP. Args: - request (~.video_stitcher_service.CreateCdnKeyRequest): + request (~.video_stitcher_service.GetCdnKeyRequest): The request object. Request message for - VideoStitcherService.createCdnKey. - + VideoStitcherService.getCdnKey. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cdn_keys.CdnKey: @@ -819,48 +3643,55 @@ def __call__( """ - http_options: List[Dict[str, str]] = [ - { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/cdnKeys", - "body": "cdn_key", - }, - ] - request, metadata = self._interceptor.pre_create_cdn_key(request, metadata) - pb_request = video_stitcher_service.CreateCdnKeyRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_http_options() + ) - body = json_format.MessageToJson( - transcoded_request["body"], - including_default_value_fields=False, - use_integers_for_enums=True, + request, metadata = self._interceptor.pre_get_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_transcoded_request( + http_options, 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 = _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetCdnKey", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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, + response = VideoStitcherServiceRestTransport._GetCdnKey._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -873,93 +3704,149 @@ def __call__( pb_resp = cdn_keys.CdnKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_cdn_key(resp) + + resp = self._interceptor.post_get_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_cdn_key_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cdn_keys.CdnKey.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_cdn_key", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _CreateLiveSession(VideoStitcherServiceRestStub): + class _GetLiveAdTagDetail( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("CreateLiveSession") - - __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 - } + return hash("VideoStitcherServiceRestTransport.GetLiveAdTagDetail") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.CreateLiveSessionRequest, + request: video_stitcher_service.GetLiveAdTagDetailRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> sessions.LiveSession: - r"""Call the create live session method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> ad_tag_details.LiveAdTagDetail: + r"""Call the get live ad tag detail method over HTTP. Args: - request (~.video_stitcher_service.CreateLiveSessionRequest): + request (~.video_stitcher_service.GetLiveAdTagDetailRequest): The request object. Request message for - VideoStitcherService.createLiveSession. - + VideoStitcherService.getLiveAdTagDetail retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.sessions.LiveSession: - Metadata for a live session. + ~.ad_tag_details.LiveAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for live sessions that do not + implement Google Ad Manager ad + insertion. + """ - http_options: List[Dict[str, str]] = [ - { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/liveSessions", - "body": "live_session", - }, - ] - request, metadata = self._interceptor.pre_create_live_session( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_http_options() ) - pb_request = video_stitcher_service.CreateLiveSessionRequest.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, + request, metadata = self._interceptor.pre_get_live_ad_tag_detail( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_transcoded_request( + http_options, 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 = _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveAdTagDetail", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveAdTagDetail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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, + response = ( + VideoStitcherServiceRestTransport._GetLiveAdTagDetail._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -968,97 +3855,146 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = sessions.LiveSession() - pb_resp = sessions.LiveSession.pb(resp) + resp = ad_tag_details.LiveAdTagDetail() + pb_resp = ad_tag_details.LiveAdTagDetail.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_live_session(resp) + + resp = self._interceptor.post_get_live_ad_tag_detail(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_live_ad_tag_detail_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ad_tag_details.LiveAdTagDetail.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_ad_tag_detail", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveAdTagDetail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _CreateSlate(VideoStitcherServiceRestStub): + class _GetLiveConfig( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("CreateSlate") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "slateId": "", - } - - @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 - } + return hash("VideoStitcherServiceRestTransport.GetLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.CreateSlateRequest, + request: video_stitcher_service.GetLiveConfigRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> slates.Slate: - r"""Call the create slate method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> live_configs.LiveConfig: + r"""Call the get live config method over HTTP. Args: - request (~.video_stitcher_service.CreateSlateRequest): + request (~.video_stitcher_service.GetLiveConfigRequest): The request object. Request message for - VideoStitcherService.createSlate. - + VideoStitcherService.getLiveConfig. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.slates.Slate: - Slate object - """ + ~.live_configs.LiveConfig: + Metadata for used to register live + configs. - http_options: List[Dict[str, str]] = [ - { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/slates", - "body": "slate", - }, - ] - request, metadata = self._interceptor.pre_create_slate(request, metadata) - pb_request = video_stitcher_service.CreateSlateRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + """ - # Jsonify the request body + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_http_options() + ) - body = json_format.MessageToJson( - transcoded_request["body"], - including_default_value_fields=False, - use_integers_for_enums=True, + request, metadata = self._interceptor.pre_get_live_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_transcoded_request( + http_options, 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 = _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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, + response = VideoStitcherServiceRestTransport._GetLiveConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1067,97 +4003,150 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = slates.Slate() - pb_resp = slates.Slate.pb(resp) + resp = live_configs.LiveConfig() + pb_resp = live_configs.LiveConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_slate(resp) + + resp = self._interceptor.post_get_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_live_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = live_configs.LiveConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _CreateVodSession(VideoStitcherServiceRestStub): + class _GetLiveSession( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("CreateVodSession") - - __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 - } + return hash("VideoStitcherServiceRestTransport.GetLiveSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.CreateVodSessionRequest, + request: video_stitcher_service.GetLiveSessionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> sessions.VodSession: - r"""Call the create vod session method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.LiveSession: + r"""Call the get live session method over HTTP. Args: - request (~.video_stitcher_service.CreateVodSessionRequest): + request (~.video_stitcher_service.GetLiveSessionRequest): The request object. Request message for - VideoStitcherService.createVodSession - + VideoStitcherService.getSession. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.sessions.VodSession: - Metadata for a VOD session. + ~.sessions.LiveSession: + Metadata for a live session. The + session expires 5 minutes after the + client stops fetching the session's + playlists. + """ - http_options: List[Dict[str, str]] = [ - { - "method": "post", - "uri": "/v1/{parent=projects/*/locations/*}/vodSessions", - "body": "vod_session", - }, - ] - request, metadata = self._interceptor.pre_create_vod_session( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_http_options() ) - pb_request = video_stitcher_service.CreateVodSessionRequest.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, + request, metadata = self._interceptor.pre_get_live_session( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_transcoded_request( + http_options, 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 = _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetLiveSession", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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, + response = VideoStitcherServiceRestTransport._GetLiveSession._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1166,82 +4155,144 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = sessions.VodSession() - pb_resp = sessions.VodSession.pb(resp) + resp = sessions.LiveSession() + pb_resp = sessions.LiveSession.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_vod_session(resp) + + resp = self._interceptor.post_get_live_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_live_session_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = sessions.LiveSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_live_session", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetLiveSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _DeleteCdnKey(VideoStitcherServiceRestStub): + class _GetSlate( + _BaseVideoStitcherServiceRestTransport._BaseGetSlate, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("DeleteCdnKey") - - __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 - } + return hash("VideoStitcherServiceRestTransport.GetSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.DeleteCdnKeyRequest, + request: video_stitcher_service.GetSlateRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ): - r"""Call the delete cdn key method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> slates.Slate: + r"""Call the get slate method over HTTP. Args: - request (~.video_stitcher_service.DeleteCdnKeyRequest): + request (~.video_stitcher_service.GetSlateRequest): The request object. Request message for - VideoStitcherService.deleteCdnKey. - + VideoStitcherService.getSlate. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.slates.Slate: + Slate object """ - http_options: List[Dict[str, str]] = [ - { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/cdnKeys/*}", - }, - ] - request, metadata = self._interceptor.pre_delete_cdn_key(request, metadata) - pb_request = video_stitcher_service.DeleteCdnKeyRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_http_options() + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_get_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetSlate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._GetSlate._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1249,75 +4300,154 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _DeleteSlate(VideoStitcherServiceRestStub): - def __hash__(self): - return hash("DeleteSlate") + # Return the response + resp = slates.Slate() + pb_resp = slates.Slate.pb(resp) - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - @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 - } + resp = self._interceptor.post_get_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_slate_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = slates.Slate.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_slate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetVodAdTagDetail( + _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetVodAdTagDetail") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.DeleteSlateRequest, + request: video_stitcher_service.GetVodAdTagDetailRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ): - r"""Call the delete slate method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> ad_tag_details.VodAdTagDetail: + r"""Call the get vod ad tag detail method over HTTP. Args: - request (~.video_stitcher_service.DeleteSlateRequest): + request (~.video_stitcher_service.GetVodAdTagDetailRequest): The request object. Request message for - VideoStitcherService.deleteSlate. - + VideoStitcherService.getVodAdTagDetail retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + ~.ad_tag_details.VodAdTagDetail: + Information related to the details + for one ad tag. This resource is only + available for VOD sessions that do not + implement Google Ad Manager ad + insertion. + """ - http_options: List[Dict[str, str]] = [ - { - "method": "delete", - "uri": "/v1/{name=projects/*/locations/*/slates/*}", - }, - ] - request, metadata = self._interceptor.pre_delete_slate(request, metadata) - pb_request = video_stitcher_service.DeleteSlateRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_http_options() + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_get_vod_ad_tag_detail( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodAdTagDetail", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodAdTagDetail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = ( + VideoStitcherServiceRestTransport._GetVodAdTagDetail._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1325,83 +4455,147 @@ def __call__( if response.status_code >= 400: raise core_exceptions.from_http_response(response) - class _GetCdnKey(VideoStitcherServiceRestStub): - def __hash__(self): - return hash("GetCdnKey") + # Return the response + resp = ad_tag_details.VodAdTagDetail() + pb_resp = ad_tag_details.VodAdTagDetail.pb(resp) - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - @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 - } + resp = self._interceptor.post_get_vod_ad_tag_detail(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_ad_tag_detail_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ad_tag_details.VodAdTagDetail.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_ad_tag_detail", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodAdTagDetail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) + return resp + + class _GetVodConfig( + _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.GetCdnKeyRequest, + request: video_stitcher_service.GetVodConfigRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> cdn_keys.CdnKey: - r"""Call the get cdn key method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> vod_configs.VodConfig: + r"""Call the get vod config method over HTTP. Args: - request (~.video_stitcher_service.GetCdnKeyRequest): + request (~.video_stitcher_service.GetVodConfigRequest): The request object. Request message for - VideoStitcherService.getCdnKey. - + VideoStitcherService.getVodConfig. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.cdn_keys.CdnKey: - Configuration for a CDN key. Used by - the Video Stitcher to sign URIs for - fetching video manifests and signing - media segments for playback. + ~.vod_configs.VodConfig: + Metadata used to register VOD + configs. """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/cdnKeys/*}", - }, - ] - request, metadata = self._interceptor.pre_get_cdn_key(request, metadata) - pb_request = video_stitcher_service.GetCdnKeyRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_http_options() + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_get_vod_config(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._GetVodConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1410,90 +4604,147 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = cdn_keys.CdnKey() - pb_resp = cdn_keys.CdnKey.pb(resp) + resp = vod_configs.VodConfig() + pb_resp = vod_configs.VodConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_cdn_key(resp) + + resp = self._interceptor.post_get_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vod_configs.VodConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _GetLiveAdTagDetail(VideoStitcherServiceRestStub): + class _GetVodSession( + _BaseVideoStitcherServiceRestTransport._BaseGetVodSession, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("GetLiveAdTagDetail") - - __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 - } + return hash("VideoStitcherServiceRestTransport.GetVodSession") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.GetLiveAdTagDetailRequest, + request: video_stitcher_service.GetVodSessionRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> ad_tag_details.LiveAdTagDetail: - r"""Call the get live ad tag detail method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> sessions.VodSession: + r"""Call the get vod session method over HTTP. Args: - request (~.video_stitcher_service.GetLiveAdTagDetailRequest): + request (~.video_stitcher_service.GetVodSessionRequest): The request object. Request message for - VideoStitcherService.getLiveAdTagDetail - + VideoStitcherService.getVodSession retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.ad_tag_details.LiveAdTagDetail: - Container for a live session's ad tag - detail. + ~.sessions.VodSession: + Metadata for a VOD session. The + session expires 4 hours after its + creation. """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/liveSessions/*/liveAdTagDetails/*}", - }, - ] - request, metadata = self._interceptor.pre_get_live_ad_tag_detail( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_http_options() ) - pb_request = video_stitcher_service.GetLiveAdTagDetailRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_get_vod_session(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodSession", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._GetVodSession._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1502,88 +4753,153 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = ad_tag_details.LiveAdTagDetail() - pb_resp = ad_tag_details.LiveAdTagDetail.pb(resp) + resp = sessions.VodSession() + pb_resp = sessions.VodSession.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_live_ad_tag_detail(resp) + + resp = self._interceptor.post_get_vod_session(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_session_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = sessions.VodSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_session", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _GetLiveSession(VideoStitcherServiceRestStub): + class _GetVodStitchDetail( + _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("GetLiveSession") - - __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 - } + return hash("VideoStitcherServiceRestTransport.GetVodStitchDetail") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.GetLiveSessionRequest, + request: video_stitcher_service.GetVodStitchDetailRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> sessions.LiveSession: - r"""Call the get live session method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> stitch_details.VodStitchDetail: + r"""Call the get vod stitch detail method over HTTP. Args: - request (~.video_stitcher_service.GetLiveSessionRequest): + request (~.video_stitcher_service.GetVodStitchDetailRequest): The request object. Request message for - VideoStitcherService.getSession. - + VideoStitcherService.getVodStitchDetail. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.sessions.LiveSession: - Metadata for a live session. + ~.stitch_details.VodStitchDetail: + Information related to the + interstitial of a VOD session. This + resource is only available for VOD + sessions that do not implement Google Ad + Manager ad insertion. + """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/liveSessions/*}", - }, - ] - request, metadata = self._interceptor.pre_get_live_session( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_http_options() ) - pb_request = video_stitcher_service.GetLiveSessionRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_get_vod_stitch_detail( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetVodStitchDetail", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodStitchDetail", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = ( + VideoStitcherServiceRestTransport._GetVodStitchDetail._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1592,86 +4908,146 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = sessions.LiveSession() - pb_resp = sessions.LiveSession.pb(resp) + resp = stitch_details.VodStitchDetail() + pb_resp = stitch_details.VodStitchDetail.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_live_session(resp) + + resp = self._interceptor.post_get_vod_stitch_detail(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_get_vod_stitch_detail_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = stitch_details.VodStitchDetail.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.get_vod_stitch_detail", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetVodStitchDetail", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _GetSlate(VideoStitcherServiceRestStub): + class _ListCdnKeys( + _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("GetSlate") - - __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 - } + return hash("VideoStitcherServiceRestTransport.ListCdnKeys") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.GetSlateRequest, + request: video_stitcher_service.ListCdnKeysRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> slates.Slate: - r"""Call the get slate method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> video_stitcher_service.ListCdnKeysResponse: + r"""Call the list cdn keys method over HTTP. Args: - request (~.video_stitcher_service.GetSlateRequest): + request (~.video_stitcher_service.ListCdnKeysRequest): The request object. Request message for - VideoStitcherService.getSlate. - + VideoStitcherService.listCdnKeys. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.slates.Slate: - Slate object + ~.video_stitcher_service.ListCdnKeysResponse: + Response message for + VideoStitcher.ListCdnKeys. + """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/slates/*}", - }, - ] - request, metadata = self._interceptor.pre_get_slate(request, metadata) - pb_request = video_stitcher_service.GetSlateRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_http_options() + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_list_cdn_keys(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListCdnKeys", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListCdnKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._ListCdnKeys._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1680,90 +5056,152 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = slates.Slate() - pb_resp = slates.Slate.pb(resp) + resp = video_stitcher_service.ListCdnKeysResponse() + pb_resp = video_stitcher_service.ListCdnKeysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_slate(resp) + + resp = self._interceptor.post_list_cdn_keys(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_cdn_keys_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + video_stitcher_service.ListCdnKeysResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_cdn_keys", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListCdnKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _GetVodAdTagDetail(VideoStitcherServiceRestStub): + class _ListLiveAdTagDetails( + _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("GetVodAdTagDetail") - - __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 - } + return hash("VideoStitcherServiceRestTransport.ListLiveAdTagDetails") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.GetVodAdTagDetailRequest, + request: video_stitcher_service.ListLiveAdTagDetailsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> ad_tag_details.VodAdTagDetail: - r"""Call the get vod ad tag detail method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> video_stitcher_service.ListLiveAdTagDetailsResponse: + r"""Call the list live ad tag details method over HTTP. Args: - request (~.video_stitcher_service.GetVodAdTagDetailRequest): + request (~.video_stitcher_service.ListLiveAdTagDetailsRequest): The request object. Request message for - VideoStitcherService.getVodAdTagDetail - + VideoStitcherService.listLiveAdTagDetails. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.ad_tag_details.VodAdTagDetail: - Information related to the details - for one ad tag. + ~.video_stitcher_service.ListLiveAdTagDetailsResponse: + Response message for + VideoStitcherService.listLiveAdTagDetails. """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/vodSessions/*/vodAdTagDetails/*}", - }, - ] - request, metadata = self._interceptor.pre_get_vod_ad_tag_detail( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_http_options() ) - pb_request = video_stitcher_service.GetVodAdTagDetailRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_list_live_ad_tag_details( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListLiveAdTagDetails", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveAdTagDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = ( + VideoStitcherServiceRestTransport._ListLiveAdTagDetails._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1772,86 +5210,152 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = ad_tag_details.VodAdTagDetail() - pb_resp = ad_tag_details.VodAdTagDetail.pb(resp) + resp = video_stitcher_service.ListLiveAdTagDetailsResponse() + pb_resp = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_vod_ad_tag_detail(resp) + + resp = self._interceptor.post_list_live_ad_tag_details(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_live_ad_tag_details_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + video_stitcher_service.ListLiveAdTagDetailsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_ad_tag_details", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveAdTagDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _GetVodSession(VideoStitcherServiceRestStub): + class _ListLiveConfigs( + _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("GetVodSession") - - __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 - } + return hash("VideoStitcherServiceRestTransport.ListLiveConfigs") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.GetVodSessionRequest, + request: video_stitcher_service.ListLiveConfigsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> sessions.VodSession: - r"""Call the get vod session method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> video_stitcher_service.ListLiveConfigsResponse: + r"""Call the list live configs method over HTTP. Args: - request (~.video_stitcher_service.GetVodSessionRequest): + request (~.video_stitcher_service.ListLiveConfigsRequest): The request object. Request message for - VideoStitcherService.getVodSession - + VideoStitcherService.listLiveConfig. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.sessions.VodSession: - Metadata for a VOD session. + ~.video_stitcher_service.ListLiveConfigsResponse: + Response message for + VideoStitcher.ListLiveConfig. + """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/vodSessions/*}", - }, - ] - request, metadata = self._interceptor.pre_get_vod_session(request, metadata) - pb_request = video_stitcher_service.GetVodSessionRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_http_options() + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_list_live_configs( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListLiveConfigs", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._ListLiveConfigs._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1860,90 +5364,148 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = sessions.VodSession() - pb_resp = sessions.VodSession.pb(resp) + resp = video_stitcher_service.ListLiveConfigsResponse() + pb_resp = video_stitcher_service.ListLiveConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_vod_session(resp) + + resp = self._interceptor.post_list_live_configs(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_live_configs_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + video_stitcher_service.ListLiveConfigsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_live_configs", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListLiveConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _GetVodStitchDetail(VideoStitcherServiceRestStub): + class _ListSlates( + _BaseVideoStitcherServiceRestTransport._BaseListSlates, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("GetVodStitchDetail") - - __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 - } + return hash("VideoStitcherServiceRestTransport.ListSlates") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.GetVodStitchDetailRequest, + request: video_stitcher_service.ListSlatesRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> stitch_details.VodStitchDetail: - r"""Call the get vod stitch detail method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> video_stitcher_service.ListSlatesResponse: + r"""Call the list slates method over HTTP. Args: - request (~.video_stitcher_service.GetVodStitchDetailRequest): + request (~.video_stitcher_service.ListSlatesRequest): The request object. Request message for - VideoStitcherService.getVodStitchDetail. - + VideoStitcherService.listSlates. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.stitch_details.VodStitchDetail: - Detailed information related to the - interstitial of a VOD session. + ~.video_stitcher_service.ListSlatesResponse: + Response message for + VideoStitcherService.listSlates. """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{name=projects/*/locations/*/vodSessions/*/vodStitchDetails/*}", - }, - ] - request, metadata = self._interceptor.pre_get_vod_stitch_detail( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_http_options() ) - pb_request = video_stitcher_service.GetVodStitchDetailRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_list_slates(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListSlates", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListSlates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._ListSlates._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -1952,88 +5514,152 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = stitch_details.VodStitchDetail() - pb_resp = stitch_details.VodStitchDetail.pb(resp) + resp = video_stitcher_service.ListSlatesResponse() + pb_resp = video_stitcher_service.ListSlatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_vod_stitch_detail(resp) + + resp = self._interceptor.post_list_slates(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_slates_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + video_stitcher_service.ListSlatesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_slates", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListSlates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _ListCdnKeys(VideoStitcherServiceRestStub): + class _ListVodAdTagDetails( + _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("ListCdnKeys") - - __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 - } + return hash("VideoStitcherServiceRestTransport.ListVodAdTagDetails") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.ListCdnKeysRequest, + request: video_stitcher_service.ListVodAdTagDetailsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> video_stitcher_service.ListCdnKeysResponse: - r"""Call the list cdn keys method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> video_stitcher_service.ListVodAdTagDetailsResponse: + r"""Call the list vod ad tag details method over HTTP. Args: - request (~.video_stitcher_service.ListCdnKeysRequest): + request (~.video_stitcher_service.ListVodAdTagDetailsRequest): The request object. Request message for - VideoStitcherService.listCdnKeys. - + VideoStitcherService.listVodAdTagDetails. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.video_stitcher_service.ListCdnKeysResponse: + ~.video_stitcher_service.ListVodAdTagDetailsResponse: Response message for - VideoStitcher.ListCdnKeys. + VideoStitcherService.listVodAdTagDetails. """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/cdnKeys", - }, - ] - request, metadata = self._interceptor.pre_list_cdn_keys(request, metadata) - pb_request = video_stitcher_service.ListCdnKeysRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_http_options() + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_list_vod_ad_tag_details( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodAdTagDetails", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodAdTagDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = ( + VideoStitcherServiceRestTransport._ListVodAdTagDetails._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2042,90 +5668,152 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = video_stitcher_service.ListCdnKeysResponse() - pb_resp = video_stitcher_service.ListCdnKeysResponse.pb(resp) + resp = video_stitcher_service.ListVodAdTagDetailsResponse() + pb_resp = video_stitcher_service.ListVodAdTagDetailsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_cdn_keys(resp) + + resp = self._interceptor.post_list_vod_ad_tag_details(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_vod_ad_tag_details_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + video_stitcher_service.ListVodAdTagDetailsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_ad_tag_details", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodAdTagDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _ListLiveAdTagDetails(VideoStitcherServiceRestStub): + class _ListVodConfigs( + _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("ListLiveAdTagDetails") - - __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 - } + return hash("VideoStitcherServiceRestTransport.ListVodConfigs") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.ListLiveAdTagDetailsRequest, + request: video_stitcher_service.ListVodConfigsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> video_stitcher_service.ListLiveAdTagDetailsResponse: - r"""Call the list live ad tag details method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> video_stitcher_service.ListVodConfigsResponse: + r"""Call the list vod configs method over HTTP. Args: - request (~.video_stitcher_service.ListLiveAdTagDetailsRequest): + request (~.video_stitcher_service.ListVodConfigsRequest): The request object. Request message for - VideoStitcherService.listLiveAdTagDetails. - + VideoStitcherService.listVodConfig. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.video_stitcher_service.ListLiveAdTagDetailsResponse: + ~.video_stitcher_service.ListVodConfigsResponse: Response message for - VideoStitcherService.listLiveAdTagDetails. + VideoStitcher.ListVodConfig. """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*/liveSessions/*}/liveAdTagDetails", - }, - ] - request, metadata = self._interceptor.pre_list_live_ad_tag_details( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_http_options() ) - pb_request = video_stitcher_service.ListLiveAdTagDetailsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_list_vod_configs( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodConfigs", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._ListVodConfigs._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2134,88 +5822,152 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = video_stitcher_service.ListLiveAdTagDetailsResponse() - pb_resp = video_stitcher_service.ListLiveAdTagDetailsResponse.pb(resp) + resp = video_stitcher_service.ListVodConfigsResponse() + pb_resp = video_stitcher_service.ListVodConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_live_ad_tag_details(resp) + + resp = self._interceptor.post_list_vod_configs(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_vod_configs_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + video_stitcher_service.ListVodConfigsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_configs", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _ListSlates(VideoStitcherServiceRestStub): + class _ListVodStitchDetails( + _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("ListSlates") - - __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 - } + return hash("VideoStitcherServiceRestTransport.ListVodStitchDetails") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response def __call__( self, - request: video_stitcher_service.ListSlatesRequest, + request: video_stitcher_service.ListVodStitchDetailsRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> video_stitcher_service.ListSlatesResponse: - r"""Call the list slates method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> video_stitcher_service.ListVodStitchDetailsResponse: + r"""Call the list vod stitch details method over HTTP. Args: - request (~.video_stitcher_service.ListSlatesRequest): + request (~.video_stitcher_service.ListVodStitchDetailsRequest): The request object. Request message for - VideoStitcherService.listSlates. - + VideoStitcherService.listVodStitchDetails. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.video_stitcher_service.ListSlatesResponse: + ~.video_stitcher_service.ListVodStitchDetailsResponse: Response message for - VideoStitcherService.listSlates. + VideoStitcherService.listVodStitchDetails. """ - http_options: List[Dict[str, str]] = [ - { - "method": "get", - "uri": "/v1/{parent=projects/*/locations/*}/slates", - }, - ] - request, metadata = self._interceptor.pre_list_slates(request, metadata) - pb_request = video_stitcher_service.ListSlatesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_http_options() + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_list_vod_stitch_details( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_transcoded_request( + http_options, request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListVodStitchDetails", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodStitchDetails", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = ( + VideoStitcherServiceRestTransport._ListVodStitchDetails._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2224,90 +5976,157 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = video_stitcher_service.ListSlatesResponse() - pb_resp = video_stitcher_service.ListSlatesResponse.pb(resp) + resp = video_stitcher_service.ListVodStitchDetailsResponse() + pb_resp = video_stitcher_service.ListVodStitchDetailsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_slates(resp) + + resp = self._interceptor.post_list_vod_stitch_details(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_list_vod_stitch_details_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + video_stitcher_service.ListVodStitchDetailsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.list_vod_stitch_details", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListVodStitchDetails", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _ListVodAdTagDetails(VideoStitcherServiceRestStub): + class _UpdateCdnKey( + _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("ListVodAdTagDetails") - - __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 - } + return hash("VideoStitcherServiceRestTransport.UpdateCdnKey") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response def __call__( self, - request: video_stitcher_service.ListVodAdTagDetailsRequest, + request: video_stitcher_service.UpdateCdnKeyRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> video_stitcher_service.ListVodAdTagDetailsResponse: - r"""Call the list vod ad tag details method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the update cdn key method over HTTP. Args: - request (~.video_stitcher_service.ListVodAdTagDetailsRequest): + request (~.video_stitcher_service.UpdateCdnKeyRequest): The request object. Request message for - VideoStitcherService.listVodAdTagDetails. - + VideoStitcherService.updateCdnKey. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.video_stitcher_service.ListVodAdTagDetailsResponse: - Response message for - VideoStitcherService.listVodAdTagDetails. + ~.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": "get", - "uri": "/v1/{parent=projects/*/locations/*/vodSessions/*}/vodAdTagDetails", - }, - ] - request, metadata = self._interceptor.pre_list_vod_ad_tag_details( - request, metadata + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_http_options() ) - pb_request = video_stitcher_service.ListVodAdTagDetailsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + request, metadata = self._interceptor.pre_update_cdn_key(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_request_body_json( + transcoded_request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateCdnKey", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateCdnKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = VideoStitcherServiceRestTransport._UpdateCdnKey._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2316,90 +6135,155 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = video_stitcher_service.ListVodAdTagDetailsResponse() - pb_resp = video_stitcher_service.ListVodAdTagDetailsResponse.pb(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_vod_ad_tag_details(resp) + resp = self._interceptor.post_update_cdn_key(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_cdn_key_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_cdn_key", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateCdnKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _ListVodStitchDetails(VideoStitcherServiceRestStub): + class _UpdateLiveConfig( + _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("ListVodStitchDetails") - - __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 - } + return hash("VideoStitcherServiceRestTransport.UpdateLiveConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response def __call__( self, - request: video_stitcher_service.ListVodStitchDetailsRequest, + request: video_stitcher_service.UpdateLiveConfigRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> video_stitcher_service.ListVodStitchDetailsResponse: - r"""Call the list vod stitch details method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the update live config method over HTTP. Args: - request (~.video_stitcher_service.ListVodStitchDetailsRequest): + request (~.video_stitcher_service.UpdateLiveConfigRequest): The request object. Request message for - VideoStitcherService.listVodStitchDetails. - + VideoStitcherService.updateLiveConfig. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.video_stitcher_service.ListVodStitchDetailsResponse: - Response message for - VideoStitcherService.listVodStitchDetails. + ~.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": "get", - "uri": "/v1/{parent=projects/*/locations/*/vodSessions/*}/vodStitchDetails", - }, - ] - request, metadata = self._interceptor.pre_list_vod_stitch_details( + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_http_options() + ) + + request, metadata = self._interceptor.pre_update_live_config( request, metadata ) - pb_request = video_stitcher_service.ListVodStitchDetailsRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_transcoded_request( + http_options, request + ) - uri = transcoded_request["uri"] - method = transcoded_request["method"] + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_request_body_json( + transcoded_request + ) # 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 = _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateLiveConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateLiveConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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), + response = ( + VideoStitcherServiceRestTransport._UpdateLiveConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, + ) ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2408,101 +6292,151 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = video_stitcher_service.ListVodStitchDetailsResponse() - pb_resp = video_stitcher_service.ListVodStitchDetailsResponse.pb(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_vod_stitch_details(resp) + resp = self._interceptor.post_update_live_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_live_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_live_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateLiveConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _UpdateCdnKey(VideoStitcherServiceRestStub): + class _UpdateSlate( + _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("UpdateCdnKey") - - __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 - } + return hash("VideoStitcherServiceRestTransport.UpdateSlate") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response def __call__( self, - request: video_stitcher_service.UpdateCdnKeyRequest, + request: video_stitcher_service.UpdateSlateRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> cdn_keys.CdnKey: - r"""Call the update cdn key method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the update slate method over HTTP. Args: - request (~.video_stitcher_service.UpdateCdnKeyRequest): + request (~.video_stitcher_service.UpdateSlateRequest): The request object. Request message for - VideoStitcherService.updateCdnKey. - + VideoStitcherService.updateSlate. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.cdn_keys.CdnKey: - Configuration for a CDN key. Used by - the Video Stitcher to sign URIs for - fetching video manifests and signing - media segments for playback. + ~.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": "/v1/{cdn_key.name=projects/*/locations/*/cdnKeys/*}", - "body": "cdn_key", - }, - ] - request, metadata = self._interceptor.pre_update_cdn_key(request, metadata) - pb_request = video_stitcher_service.UpdateCdnKeyRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_http_options() + ) - # Jsonify the request body + request, metadata = self._interceptor.pre_update_slate(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_transcoded_request( + http_options, request + ) - body = json_format.MessageToJson( - transcoded_request["body"], - including_default_value_fields=False, - use_integers_for_enums=True, + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_request_body_json( + transcoded_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 = _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateSlate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateSlate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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, + response = VideoStitcherServiceRestTransport._UpdateSlate._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2511,97 +6445,153 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = cdn_keys.CdnKey() - pb_resp = cdn_keys.CdnKey.pb(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_cdn_key(resp) + resp = self._interceptor.post_update_slate(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_slate_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_slate", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateSlate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp - class _UpdateSlate(VideoStitcherServiceRestStub): + class _UpdateVodConfig( + _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig, + VideoStitcherServiceRestStub, + ): def __hash__(self): - return hash("UpdateSlate") - - __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 - } + return hash("VideoStitcherServiceRestTransport.UpdateVodConfig") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response def __call__( self, - request: video_stitcher_service.UpdateSlateRequest, + request: video_stitcher_service.UpdateVodConfigRequest, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), - ) -> slates.Slate: - r"""Call the update slate method over HTTP. + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> operations_pb2.Operation: + r"""Call the update vod config method over HTTP. Args: - request (~.video_stitcher_service.UpdateSlateRequest): + request (~.video_stitcher_service.UpdateVodConfigRequest): The request object. Request message for - VideoStitcherService.updateSlate. - + VideoStitcherService.updateVodConfig. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: - ~.slates.Slate: - Slate object + ~.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": "/v1/{slate.name=projects/*/locations/*/slates/*}", - "body": "slate", - }, - ] - request, metadata = self._interceptor.pre_update_slate(request, metadata) - pb_request = video_stitcher_service.UpdateSlateRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_http_options() + ) - # Jsonify the request body + request, metadata = self._interceptor.pre_update_vod_config( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_transcoded_request( + http_options, request + ) - body = json_format.MessageToJson( - transcoded_request["body"], - including_default_value_fields=False, - use_integers_for_enums=True, + body = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_request_body_json( + transcoded_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 = _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_query_params_json( + transcoded_request ) - query_params.update(self._get_unset_required_fields(query_params)) - query_params["$alt"] = "json;enum-encoding=int" + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.UpdateVodConfig", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateVodConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) # Send the request - headers = dict(metadata) - headers["Content-Type"] = "application/json" - response = 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, + response = VideoStitcherServiceRestTransport._UpdateVodConfig._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + body, ) # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception @@ -2610,21 +6600,57 @@ def __call__( raise core_exceptions.from_http_response(response) # Return the response - resp = slates.Slate() - pb_resp = slates.Slate.pb(resp) + resp = operations_pb2.Operation() + json_format.Parse(response.content, resp, ignore_unknown_fields=True) - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_slate(resp) + resp = self._interceptor.post_update_vod_config(resp) + response_metadata = [(k, str(v)) for k, v in response.headers.items()] + resp, _ = self._interceptor.post_update_vod_config_with_metadata( + resp, response_metadata + ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.update_vod_config", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "UpdateVodConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property def create_cdn_key( self, - ) -> Callable[[video_stitcher_service.CreateCdnKeyRequest], cdn_keys.CdnKey]: + ) -> Callable[ + [video_stitcher_service.CreateCdnKeyRequest], 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._CreateCdnKey(self._session, self._host, self._interceptor) # type: ignore + @property + def create_live_config( + self, + ) -> Callable[ + [video_stitcher_service.CreateLiveConfigRequest], 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._CreateLiveConfig(self._session, self._host, self._interceptor) # type: ignore + @property def create_live_session( self, @@ -2638,10 +6664,22 @@ def create_live_session( @property def create_slate( self, - ) -> Callable[[video_stitcher_service.CreateSlateRequest], slates.Slate]: + ) -> Callable[ + [video_stitcher_service.CreateSlateRequest], 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._CreateSlate(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_vod_config( + self, + ) -> Callable[ + [video_stitcher_service.CreateVodConfigRequest], 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._CreateSlate(self._session, self._host, self._interceptor) # type: ignore + return self._CreateVodConfig(self._session, self._host, self._interceptor) # type: ignore @property def create_vod_session( @@ -2656,19 +6694,43 @@ def create_vod_session( @property def delete_cdn_key( self, - ) -> Callable[[video_stitcher_service.DeleteCdnKeyRequest], empty_pb2.Empty]: + ) -> Callable[ + [video_stitcher_service.DeleteCdnKeyRequest], 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._DeleteCdnKey(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_live_config( + self, + ) -> Callable[ + [video_stitcher_service.DeleteLiveConfigRequest], 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._DeleteLiveConfig(self._session, self._host, self._interceptor) # type: ignore + @property def delete_slate( self, - ) -> Callable[[video_stitcher_service.DeleteSlateRequest], empty_pb2.Empty]: + ) -> Callable[ + [video_stitcher_service.DeleteSlateRequest], 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._DeleteSlate(self._session, self._host, self._interceptor) # type: ignore + @property + def delete_vod_config( + self, + ) -> Callable[ + [video_stitcher_service.DeleteVodConfigRequest], 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._DeleteVodConfig(self._session, self._host, self._interceptor) # type: ignore + @property def get_cdn_key( self, @@ -2688,6 +6750,16 @@ def get_live_ad_tag_detail( # In C++ this would require a dynamic_cast return self._GetLiveAdTagDetail(self._session, self._host, self._interceptor) # type: ignore + @property + def get_live_config( + self, + ) -> Callable[ + [video_stitcher_service.GetLiveConfigRequest], live_configs.LiveConfig + ]: + # 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._GetLiveConfig(self._session, self._host, self._interceptor) # type: ignore + @property def get_live_session( self, @@ -2714,6 +6786,14 @@ def get_vod_ad_tag_detail( # In C++ this would require a dynamic_cast return self._GetVodAdTagDetail(self._session, self._host, self._interceptor) # type: ignore + @property + def get_vod_config( + self, + ) -> Callable[[video_stitcher_service.GetVodConfigRequest], vod_configs.VodConfig]: + # 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._GetVodConfig(self._session, self._host, self._interceptor) # type: ignore + @property def get_vod_session( self, @@ -2755,6 +6835,17 @@ def list_live_ad_tag_details( # In C++ this would require a dynamic_cast return self._ListLiveAdTagDetails(self._session, self._host, self._interceptor) # type: ignore + @property + def list_live_configs( + self, + ) -> Callable[ + [video_stitcher_service.ListLiveConfigsRequest], + video_stitcher_service.ListLiveConfigsResponse, + ]: + # 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._ListLiveConfigs(self._session, self._host, self._interceptor) # type: ignore + @property def list_slates( self, @@ -2777,6 +6868,17 @@ def list_vod_ad_tag_details( # In C++ this would require a dynamic_cast return self._ListVodAdTagDetails(self._session, self._host, self._interceptor) # type: ignore + @property + def list_vod_configs( + self, + ) -> Callable[ + [video_stitcher_service.ListVodConfigsRequest], + video_stitcher_service.ListVodConfigsResponse, + ]: + # 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._ListVodConfigs(self._session, self._host, self._interceptor) # type: ignore + @property def list_vod_stitch_details( self, @@ -2791,19 +6893,561 @@ def list_vod_stitch_details( @property def update_cdn_key( self, - ) -> Callable[[video_stitcher_service.UpdateCdnKeyRequest], cdn_keys.CdnKey]: + ) -> Callable[ + [video_stitcher_service.UpdateCdnKeyRequest], 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._UpdateCdnKey(self._session, self._host, self._interceptor) # type: ignore + @property + def update_live_config( + self, + ) -> Callable[ + [video_stitcher_service.UpdateLiveConfigRequest], 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._UpdateLiveConfig(self._session, self._host, self._interceptor) # type: ignore + @property def update_slate( self, - ) -> Callable[[video_stitcher_service.UpdateSlateRequest], slates.Slate]: + ) -> Callable[ + [video_stitcher_service.UpdateSlateRequest], 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._UpdateSlate(self._session, self._host, self._interceptor) # type: ignore + @property + def update_vod_config( + self, + ) -> Callable[ + [video_stitcher_service.UpdateVodConfigRequest], 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._UpdateVodConfig(self._session, self._host, self._interceptor) # type: ignore + + @property + def cancel_operation(self): + return self._CancelOperation(self._session, self._host, self._interceptor) # type: ignore + + class _CancelOperation( + _BaseVideoStitcherServiceRestTransport._BaseCancelOperation, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.CancelOperation") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + return response + + def __call__( + self, + request: operations_pb2.CancelOperationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_http_options() + ) + + request, metadata = self._interceptor.pre_cancel_operation( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_transcoded_request( + http_options, request + ) + + body = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_request_body_json( + transcoded_request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseCancelOperation._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._CancelOperation._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + 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 self._interceptor.post_cancel_operation(None) + + @property + def delete_operation(self): + return self._DeleteOperation(self._session, self._host, self._interceptor) # type: ignore + + class _DeleteOperation( + _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.DeleteOperation") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: operations_pb2.DeleteOperationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> None: + r"""Call the delete operation method over HTTP. + + Args: + request (operations_pb2.DeleteOperationRequest): + The request object for DeleteOperation method. + retry (google.api_core.retry.Retry): Designation of what errors, if any, + should be retried. + timeout (float): The timeout for this request. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_http_options() + ) + + request, metadata = self._interceptor.pre_delete_operation( + request, metadata + ) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseDeleteOperation._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._DeleteOperation._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # 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_delete_operation(None) + + @property + def get_operation(self): + return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore + + class _GetOperation( + _BaseVideoStitcherServiceRestTransport._BaseGetOperation, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.GetOperation") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: operations_pb2.GetOperationRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + operations_pb2.Operation: Response from GetOperation method. + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_http_options() + ) + + request, metadata = self._interceptor.pre_get_operation(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseGetOperation._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._GetOperation._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + content = response.content.decode("utf-8") + resp = operations_pb2.Operation() + resp = json_format.Parse(content, resp) + resp = self._interceptor.post_get_operation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + + @property + def list_operations(self): + return self._ListOperations(self._session, self._host, self._interceptor) # type: ignore + + class _ListOperations( + _BaseVideoStitcherServiceRestTransport._BaseListOperations, + VideoStitcherServiceRestStub, + ): + def __hash__(self): + return hash("VideoStitcherServiceRestTransport.ListOperations") + + @staticmethod + def _get_response( + host, + metadata, + query_params, + session, + timeout, + transcoded_request, + body=None, + ): + uri = transcoded_request["uri"] + method = transcoded_request["method"] + headers = dict(metadata) + headers["Content-Type"] = "application/json" + response = getattr(session, method)( + "{host}{uri}".format(host=host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + return response + + def __call__( + self, + request: operations_pb2.ListOperationsRequest, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Optional[float] = None, + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), + ) -> 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, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. + + Returns: + operations_pb2.ListOperationsResponse: Response from ListOperations method. + """ + + http_options = ( + _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_http_options() + ) + + request, metadata = self._interceptor.pre_list_operations(request, metadata) + transcoded_request = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_transcoded_request( + http_options, request + ) + + # Jsonify the query params + query_params = _BaseVideoStitcherServiceRestTransport._BaseListOperations._get_query_params_json( + transcoded_request + ) + + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.video.stitcher_v1.VideoStitcherServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request + response = VideoStitcherServiceRestTransport._ListOperations._get_response( + self._host, + metadata, + query_params, + self._session, + timeout, + transcoded_request, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + content = response.content.decode("utf-8") + resp = operations_pb2.ListOperationsResponse() + resp = json_format.Parse(content, resp) + resp = self._interceptor.post_list_operations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.video.stitcher_v1.VideoStitcherServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.video.stitcher.v1.VideoStitcherService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) + return resp + @property def kind(self) -> str: return "rest" diff --git a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py similarity index 51% rename from owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py rename to packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py index 8b3bd977873e..07f32682b8a0 100644 --- a/owl-bot-staging/google-cloud-video-stitcher/v1/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py +++ b/packages/google-cloud-video-stitcher/google/cloud/video/stitcher_v1/services/video_stitcher_service/transports/rest_base.py @@ -14,25 +14,25 @@ # limitations under the License. # import json # type: ignore -from google.api_core import path_template -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from .base import VideoStitcherServiceTransport, DEFAULT_CLIENT_INFO - import re from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union - -from google.cloud.video.stitcher_v1.types import ad_tag_details -from google.cloud.video.stitcher_v1.types import cdn_keys -from google.cloud.video.stitcher_v1.types import live_configs -from google.cloud.video.stitcher_v1.types import sessions -from google.cloud.video.stitcher_v1.types import slates -from google.cloud.video.stitcher_v1.types import stitch_details -from google.cloud.video.stitcher_v1.types import video_stitcher_service -from google.cloud.video.stitcher_v1.types import vod_configs +from google.api_core import gapic_v1, path_template from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import json_format + +from google.cloud.video.stitcher_v1.types import ( + ad_tag_details, + cdn_keys, + live_configs, + sessions, + slates, + stitch_details, + video_stitcher_service, + vod_configs, +) + +from .base import DEFAULT_CLIENT_INFO, VideoStitcherServiceTransport class _BaseVideoStitcherServiceRestTransport(VideoStitcherServiceTransport): @@ -48,14 +48,16 @@ class _BaseVideoStitcherServiceRestTransport(VideoStitcherServiceTransport): It sends JSON representations of protocol buffers over HTTP/1.1 """ - def __init__(self, *, - host: str = 'videostitcher.googleapis.com', - credentials: Optional[Any] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = 'https', - api_audience: Optional[str] = None, - ) -> None: + def __init__( + self, + *, + host: str = "videostitcher.googleapis.com", + credentials: Optional[Any] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = "https", + api_audience: Optional[str] = None, + ) -> None: """Instantiate the transport. Args: host (Optional[str]): @@ -79,7 +81,9 @@ def __init__(self, *, # Run the base constructor 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 + raise ValueError( + f"Unexpected hostname structure: {host}" + ) # pragma: NO COVER url_match_items = maybe_url_match.groupdict() @@ -90,27 +94,33 @@ def __init__(self, *, credentials=credentials, client_info=client_info, always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience + api_audience=api_audience, ) class _BaseCreateCdnKey: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "cdnKeyId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "cdnKeyId": "", + } @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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/cdnKeys', - 'body': 'cdn_key', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/cdnKeys", + "body": "cdn_key", + }, ] return http_options @@ -125,17 +135,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseCreateCdnKey._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -144,20 +160,26 @@ class _BaseCreateLiveConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "liveConfigId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "liveConfigId": "", + } @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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/liveConfigs', - 'body': 'live_config', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/liveConfigs", + "body": "live_config", + }, ] return http_options @@ -172,17 +194,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseCreateLiveConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -191,20 +219,24 @@ class _BaseCreateLiveSession: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/liveSessions', - 'body': 'live_session', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/liveSessions", + "body": "live_session", + }, ] return http_options @@ -219,17 +251,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseCreateLiveSession._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -238,20 +276,26 @@ class _BaseCreateSlate: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "slateId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "slateId": "", + } @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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/slates', - 'body': 'slate', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/slates", + "body": "slate", + }, ] return http_options @@ -266,17 +310,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseCreateSlate._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -285,20 +335,26 @@ class _BaseCreateVodConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "vodConfigId" : "", } + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "vodConfigId": "", + } @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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/vodConfigs', - 'body': 'vod_config', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/vodConfigs", + "body": "vod_config", + }, ] return http_options @@ -313,17 +369,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseCreateVodConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -332,20 +394,24 @@ class _BaseCreateVodSession: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/vodSessions', - 'body': 'vod_session', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{parent=projects/*/locations/*}/vodSessions", + "body": "vod_session", + }, ] return http_options @@ -360,17 +426,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseCreateVodSession._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -379,19 +451,23 @@ class _BaseDeleteCdnKey: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/cdnKeys/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/cdnKeys/*}", + }, ] return http_options @@ -403,11 +479,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseDeleteCdnKey._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -416,19 +498,23 @@ class _BaseDeleteLiveConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/liveConfigs/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/liveConfigs/*}", + }, ] return http_options @@ -440,11 +526,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseDeleteLiveConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -453,19 +545,23 @@ class _BaseDeleteSlate: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/slates/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/slates/*}", + }, ] return http_options @@ -477,11 +573,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseDeleteSlate._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -490,19 +592,23 @@ class _BaseDeleteVodConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/vodConfigs/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/vodConfigs/*}", + }, ] return http_options @@ -514,11 +620,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseDeleteVodConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -527,19 +639,23 @@ class _BaseGetCdnKey: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/cdnKeys/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/cdnKeys/*}", + }, ] return http_options @@ -551,11 +667,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetCdnKey._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -564,19 +686,23 @@ class _BaseGetLiveAdTagDetail: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/liveSessions/*/liveAdTagDetails/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/liveSessions/*/liveAdTagDetails/*}", + }, ] return http_options @@ -588,11 +714,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveAdTagDetail._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -601,19 +733,23 @@ class _BaseGetLiveConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/liveConfigs/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/liveConfigs/*}", + }, ] return http_options @@ -625,11 +761,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -638,19 +780,23 @@ class _BaseGetLiveSession: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/liveSessions/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/liveSessions/*}", + }, ] return http_options @@ -662,11 +808,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetLiveSession._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -675,19 +827,23 @@ class _BaseGetSlate: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/slates/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/slates/*}", + }, ] return http_options @@ -699,11 +855,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetSlate._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -712,19 +874,23 @@ class _BaseGetVodAdTagDetail: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/vodSessions/*/vodAdTagDetails/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/vodSessions/*/vodAdTagDetails/*}", + }, ] return http_options @@ -736,11 +902,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetVodAdTagDetail._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -749,19 +921,23 @@ class _BaseGetVodConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/vodConfigs/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/vodConfigs/*}", + }, ] return http_options @@ -773,11 +949,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetVodConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -786,19 +968,23 @@ class _BaseGetVodSession: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/vodSessions/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/vodSessions/*}", + }, ] return http_options @@ -810,11 +996,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetVodSession._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -823,19 +1015,23 @@ class _BaseGetVodStitchDetail: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/vodSessions/*/vodStitchDetails/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/vodSessions/*/vodStitchDetails/*}", + }, ] return http_options @@ -847,11 +1043,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseGetVodStitchDetail._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -860,19 +1062,23 @@ class _BaseListCdnKeys: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/cdnKeys', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/cdnKeys", + }, ] return http_options @@ -884,11 +1090,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseListCdnKeys._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -897,19 +1109,23 @@ class _BaseListLiveAdTagDetails: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/liveSessions/*}/liveAdTagDetails', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/liveSessions/*}/liveAdTagDetails", + }, ] return http_options @@ -921,11 +1137,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseListLiveAdTagDetails._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -934,19 +1156,23 @@ class _BaseListLiveConfigs: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/liveConfigs', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/liveConfigs", + }, ] return http_options @@ -958,11 +1184,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseListLiveConfigs._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -971,19 +1203,23 @@ class _BaseListSlates: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/slates', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/slates", + }, ] return http_options @@ -995,11 +1231,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListSlates._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseListSlates._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1008,19 +1250,23 @@ class _BaseListVodAdTagDetails: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/vodSessions/*}/vodAdTagDetails', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/vodSessions/*}/vodAdTagDetails", + }, ] return http_options @@ -1032,11 +1278,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseListVodAdTagDetails._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1045,19 +1297,23 @@ class _BaseListVodConfigs: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/vodConfigs', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*}/vodConfigs", + }, ] return http_options @@ -1069,11 +1325,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseListVodConfigs._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1082,19 +1344,23 @@ class _BaseListVodStitchDetails: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*/vodSessions/*}/vodStitchDetails', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{parent=projects/*/locations/*/vodSessions/*}/vodStitchDetails", + }, ] return http_options @@ -1106,11 +1372,17 @@ def _get_transcoded_request(http_options, request): @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseListVodStitchDetails._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1119,20 +1391,26 @@ class _BaseUpdateCdnKey: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{cdn_key.name=projects/*/locations/*/cdnKeys/*}', - 'body': 'cdn_key', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{cdn_key.name=projects/*/locations/*/cdnKeys/*}", + "body": "cdn_key", + }, ] return http_options @@ -1147,17 +1425,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseUpdateCdnKey._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1166,20 +1450,26 @@ class _BaseUpdateLiveConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{live_config.name=projects/*/locations/*/liveConfigs/*}', - 'body': 'live_config', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{live_config.name=projects/*/locations/*/liveConfigs/*}", + "body": "live_config", + }, ] return http_options @@ -1194,17 +1484,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseUpdateLiveConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1213,20 +1509,26 @@ class _BaseUpdateSlate: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{slate.name=projects/*/locations/*/slates/*}', - 'body': 'slate', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{slate.name=projects/*/locations/*/slates/*}", + "body": "slate", + }, ] return http_options @@ -1241,17 +1543,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseUpdateSlate._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1260,20 +1568,26 @@ class _BaseUpdateVodConfig: def __hash__(self): # pragma: NO COVER return NotImplementedError("__hash__ must be implemented.") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } + __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} + return { + k: v + for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() + if k not in message_dict + } @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{vod_config.name=projects/*/locations/*/vodConfigs/*}', - 'body': 'vod_config', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "patch", + "uri": "/v1/{vod_config.name=projects/*/locations/*/vodConfigs/*}", + "body": "vod_config", + }, ] return http_options @@ -1288,17 +1602,23 @@ def _get_request_body_json(transcoded_request): # Jsonify the request body body = json_format.MessageToJson( - transcoded_request['body'], - use_integers_for_enums=True + transcoded_request["body"], use_integers_for_enums=True ) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - use_integers_for_enums=True, - )) - query_params.update(_BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_unset_required_fields(query_params)) + query_params = json.loads( + json_format.MessageToJson( + transcoded_request["query_params"], + use_integers_for_enums=True, + ) + ) + query_params.update( + _BaseVideoStitcherServiceRestTransport._BaseUpdateVodConfig._get_unset_required_fields( + query_params + ) + ) query_params["$alt"] = "json;enum-encoding=int" return query_params @@ -1309,28 +1629,29 @@ def __hash__(self): # pragma: NO COVER @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}:cancel', - 'body': '*', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "post", + "uri": "/v1/{name=projects/*/locations/*/operations/*}:cancel", + "body": "*", + }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) return transcoded_request @staticmethod def _get_request_body_json(transcoded_request): - body = json.dumps(transcoded_request['body']) + body = json.dumps(transcoded_request["body"]) return body + @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) return query_params class _BaseDeleteOperation: @@ -1339,23 +1660,23 @@ def __hash__(self): # pragma: NO COVER @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "delete", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) return transcoded_request @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) return query_params class _BaseGetOperation: @@ -1364,23 +1685,23 @@ def __hash__(self): # pragma: NO COVER @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/operations/*}', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*/operations/*}", + }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) return transcoded_request @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) return query_params class _BaseListOperations: @@ -1389,26 +1710,24 @@ def __hash__(self): # pragma: NO COVER @staticmethod def _get_http_options(): - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}/operations', - }, + http_options: List[Dict[str, str]] = [ + { + "method": "get", + "uri": "/v1/{name=projects/*/locations/*}/operations", + }, ] return http_options @staticmethod def _get_transcoded_request(http_options, request): request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) + transcoded_request = path_template.transcode(http_options, **request_kwargs) return transcoded_request @staticmethod def _get_query_params_json(transcoded_request): - query_params = json.loads(json.dumps(transcoded_request['query_params'])) + query_params = json.loads(json.dumps(transcoded_request["query_params"])) return query_params -__all__=( - '_BaseVideoStitcherServiceRestTransport', -) +__all__ = ("_BaseVideoStitcherServiceRestTransport",) diff --git a/packages/google-cloud-video-stitcher/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py b/packages/google-cloud-video-stitcher/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py index 4fb50afc18a3..7d4d501b4aa2 100644 --- a/packages/google-cloud-video-stitcher/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py +++ b/packages/google-cloud-video-stitcher/tests/unit/gapic/stitcher_v1/test_video_stitcher_service.py @@ -22,15 +22,19 @@ except ImportError: # pragma: NO COVER import mock +from collections.abc import AsyncIterable, Iterable import json import math from google.api_core import api_core_version +from google.protobuf import json_format import grpc from grpc.experimental import aio from proto.marshal.rules import wrappers from proto.marshal.rules.dates import DurationRule, TimestampRule import pytest +from requests import PreparedRequest, Request, Response +from requests.sessions import Session try: from google.auth.aio import credentials as ga_credentials_async @@ -409,6 +413,7 @@ def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code): [ (VideoStitcherServiceClient, "grpc"), (VideoStitcherServiceAsyncClient, "grpc_asyncio"), + (VideoStitcherServiceClient, "rest"), ], ) def test_video_stitcher_service_client_from_service_account_info( @@ -424,7 +429,11 @@ def test_video_stitcher_service_client_from_service_account_info( assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == ("videostitcher.googleapis.com:443") + assert client.transport._host == ( + "videostitcher.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://videostitcher.googleapis.com" + ) @pytest.mark.parametrize( @@ -432,6 +441,7 @@ def test_video_stitcher_service_client_from_service_account_info( [ (transports.VideoStitcherServiceGrpcTransport, "grpc"), (transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.VideoStitcherServiceRestTransport, "rest"), ], ) def test_video_stitcher_service_client_service_account_always_use_jwt( @@ -457,6 +467,7 @@ def test_video_stitcher_service_client_service_account_always_use_jwt( [ (VideoStitcherServiceClient, "grpc"), (VideoStitcherServiceAsyncClient, "grpc_asyncio"), + (VideoStitcherServiceClient, "rest"), ], ) def test_video_stitcher_service_client_from_service_account_file( @@ -479,13 +490,18 @@ def test_video_stitcher_service_client_from_service_account_file( assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == ("videostitcher.googleapis.com:443") + assert client.transport._host == ( + "videostitcher.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://videostitcher.googleapis.com" + ) def test_video_stitcher_service_client_get_transport_class(): transport = VideoStitcherServiceClient.get_transport_class() available_transports = [ transports.VideoStitcherServiceGrpcTransport, + transports.VideoStitcherServiceRestTransport, ] assert transport in available_transports @@ -506,6 +522,11 @@ def test_video_stitcher_service_client_get_transport_class(): transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", ), + ( + VideoStitcherServiceClient, + transports.VideoStitcherServiceRestTransport, + "rest", + ), ], ) @mock.patch.object( @@ -675,6 +696,18 @@ def test_video_stitcher_service_client_client_options( "grpc_asyncio", "false", ), + ( + VideoStitcherServiceClient, + transports.VideoStitcherServiceRestTransport, + "rest", + "true", + ), + ( + VideoStitcherServiceClient, + transports.VideoStitcherServiceRestTransport, + "rest", + "false", + ), ], ) @mock.patch.object( @@ -993,6 +1026,11 @@ def test_video_stitcher_service_client_client_api_endpoint(client_class): transports.VideoStitcherServiceGrpcAsyncIOTransport, "grpc_asyncio", ), + ( + VideoStitcherServiceClient, + transports.VideoStitcherServiceRestTransport, + "rest", + ), ], ) def test_video_stitcher_service_client_client_options_scopes( @@ -1035,6 +1073,12 @@ def test_video_stitcher_service_client_client_options_scopes( "grpc_asyncio", grpc_helpers_async, ), + ( + VideoStitcherServiceClient, + transports.VideoStitcherServiceRestTransport, + "rest", + None, + ), ], ) def test_video_stitcher_service_client_client_options_credentials_file( @@ -12892,801 +12936,12905 @@ async def test_update_vod_config_flattened_error_async(): ) -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): +def test_create_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport=transport, + transport="rest", ) - # It is an error to provide a credentials file and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() - # It is an error to provide an api_key and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options=options, - transport=transport, - ) + # Ensure method has been cached + assert client._transport.create_cdn_key in client._transport._wrapped_methods - # It is an error to provide an api_key and a credential. - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options=options, credentials=ga_credentials.AnonymousCredentials() + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. ) + client._transport._wrapped_methods[client._transport.create_cdn_key] = mock_rpc - # It is an error to provide scopes and a transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = VideoStitcherServiceClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) + request = {} + client.create_cdn_key(request) + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = VideoStitcherServiceClient(transport=transport) - assert client.transport is transport + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + client.create_cdn_key(request) -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.VideoStitcherServiceGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 - transport = transports.VideoStitcherServiceGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel +def test_create_cdn_key_rest_required_fields( + request_type=video_stitcher_service.CreateCdnKeyRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport -@pytest.mark.parametrize( - "transport_class", - [ - transports.VideoStitcherServiceGrpcTransport, - transports.VideoStitcherServiceGrpcAsyncIOTransport, - ], -) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, "default") as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() + request_init = {} + request_init["parent"] = "" + request_init["cdn_key_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + # verify fields with default values are dropped + assert "cdnKeyId" not in jsonified_request -def test_transport_kind_grpc(): - transport = VideoStitcherServiceClient.get_transport_class("grpc")( + unset_fields = transport_class( credentials=ga_credentials.AnonymousCredentials() - ) - assert transport.kind == "grpc" + ).create_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + # verify required fields with default values are now present + assert "cdnKeyId" in jsonified_request + assert jsonified_request["cdnKeyId"] == request_init["cdn_key_id"] -def test_initialize_client_w_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc" - ) - assert client is not None + jsonified_request["parent"] = "parent_value" + jsonified_request["cdnKeyId"] = "cdn_key_id_value" + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_cdn_key._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("cdn_key_id",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "cdnKeyId" in jsonified_request + assert jsonified_request["cdnKeyId"] == "cdn_key_id_value" -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_cdn_key_empty_call_grpc(): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_cdn_key), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_cdn_key(request=None) + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateCdnKeyRequest() + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) - assert args[0] == request_msg + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_cdn_key(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_cdn_keys_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + expected_params = [ + ( + "cdnKeyId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_cdn_keys), "__call__") as call: - call.return_value = video_stitcher_service.ListCdnKeysResponse() - client.list_cdn_keys(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListCdnKeysRequest() +def test_create_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) - assert args[0] == request_msg + unset_fields = transport.create_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("cdnKeyId",)) + & set( + ( + "parent", + "cdnKey", + "cdnKeyId", + ) + ) + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_cdn_key_empty_call_grpc(): +def test_create_cdn_key_rest_flattened(): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_cdn_key), "__call__") as call: - call.return_value = cdn_keys.CdnKey() - client.get_cdn_key(request=None) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetCdnKeyRequest() + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} - assert args[0] == request_msg + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + cdn_key=cdn_keys.CdnKey( + google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b"private_key_blob") + ), + cdn_key_id="cdn_key_id_value", + ) + mock_args.update(sample_request) + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_cdn_key_empty_call_grpc(): + client.create_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/cdnKeys" % client.transport._host, + args[1], + ) + + +def test_create_cdn_key_rest_flattened_error(transport: str = "rest"): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport=transport, ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_cdn_key), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_cdn_key(request=None) + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_cdn_key( + video_stitcher_service.CreateCdnKeyRequest(), + parent="parent_value", + cdn_key=cdn_keys.CdnKey( + google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b"private_key_blob") + ), + cdn_key_id="cdn_key_id_value", + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteCdnKeyRequest() - assert args[0] == request_msg +def test_list_cdn_keys_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_cdn_key_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + # Ensure method has been cached + assert client._transport.list_cdn_keys in client._transport._wrapped_methods - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_cdn_key), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_cdn_key(request=None) + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_cdn_keys] = mock_rpc - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateCdnKeyRequest() + request = {} + client.list_cdn_keys(request) - assert args[0] == request_msg + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_cdn_keys(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_cdn_keys_rest_required_fields( + request_type=video_stitcher_service.ListCdnKeysRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_cdn_keys._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_cdn_keys._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListCdnKeysResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_cdn_keys(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_cdn_keys_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_cdn_keys._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_cdn_keys_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListCdnKeysResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_cdn_keys(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/cdnKeys" % client.transport._host, + args[1], + ) + + +def test_list_cdn_keys_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_cdn_keys( + video_stitcher_service.ListCdnKeysRequest(), + parent="parent_value", + ) + + +def test_list_cdn_keys_rest_pager(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + next_page_token="abc", + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[], + next_page_token="def", + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + ], + next_page_token="ghi", + ), + video_stitcher_service.ListCdnKeysResponse( + cdn_keys=[ + cdn_keys.CdnKey(), + cdn_keys.CdnKey(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + video_stitcher_service.ListCdnKeysResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_cdn_keys(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, cdn_keys.CdnKey) for i in results) + + pages = list(client.list_cdn_keys(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_cdn_key] = mock_rpc + + request = {} + client.get_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_cdn_key_rest_required_fields( + request_type=video_stitcher_service.GetCdnKeyRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = cdn_keys.CdnKey() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = cdn_keys.CdnKey.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_cdn_key(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_cdn_key_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = cdn_keys.CdnKey() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = cdn_keys.CdnKey.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, + args[1], + ) + + +def test_get_cdn_key_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_cdn_key( + video_stitcher_service.GetCdnKeyRequest(), + name="name_value", + ) + + +def test_delete_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_cdn_key] = mock_rpc + + request = {} + client.delete_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_cdn_key_rest_required_fields( + request_type=video_stitcher_service.DeleteCdnKeyRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_cdn_key(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_cdn_key_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/cdnKeys/*}" % client.transport._host, + args[1], + ) + + +def test_delete_cdn_key_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_cdn_key( + video_stitcher_service.DeleteCdnKeyRequest(), + name="name_value", + ) + + +def test_update_cdn_key_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_cdn_key in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_cdn_key] = mock_rpc + + request = {} + client.update_cdn_key(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_cdn_key(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_cdn_key_rest_required_fields( + request_type=video_stitcher_service.UpdateCdnKeyRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_cdn_key._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_cdn_key._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_cdn_key(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_cdn_key_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_cdn_key._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "cdnKey", + "updateMask", + ) + ) + ) + + +def test_update_cdn_key_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "cdn_key": {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + } + + # get truthy value for each flattened field + mock_args = dict( + cdn_key=cdn_keys.CdnKey( + google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b"private_key_blob") + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_cdn_key(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{cdn_key.name=projects/*/locations/*/cdnKeys/*}" + % client.transport._host, + args[1], + ) + + +def test_update_cdn_key_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_cdn_key( + video_stitcher_service.UpdateCdnKeyRequest(), + cdn_key=cdn_keys.CdnKey( + google_cdn_key=cdn_keys.GoogleCdnKey(private_key=b"private_key_blob") + ), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_create_vod_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_vod_session in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_vod_session + ] = mock_rpc + + request = {} + client.create_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_vod_session_rest_required_fields( + request_type=video_stitcher_service.CreateVodSessionRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_vod_session(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_vod_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_vod_session._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "vodSession", + ) + ) + ) + + +def test_create_vod_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + vod_session=sessions.VodSession(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_vod_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/vodSessions" + % client.transport._host, + args[1], + ) + + +def test_create_vod_session_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_vod_session( + video_stitcher_service.CreateVodSessionRequest(), + parent="parent_value", + vod_session=sessions.VodSession(name="name_value"), + ) + + +def test_get_vod_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_vod_session] = mock_rpc + + request = {} + client.get_vod_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_session_rest_required_fields( + request_type=video_stitcher_service.GetVodSessionRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_session(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_vod_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_vod_session._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_vod_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/vodSessions/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/vodSessions/*}" + % client.transport._host, + args[1], + ) + + +def test_get_vod_session_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_session( + video_stitcher_service.GetVodSessionRequest(), + name="name_value", + ) + + +def test_list_vod_stitch_details_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_vod_stitch_details + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_vod_stitch_details + ] = mock_rpc + + request = {} + client.list_vod_stitch_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_stitch_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_vod_stitch_details_rest_required_fields( + request_type=video_stitcher_service.ListVodStitchDetailsRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_vod_stitch_details._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_vod_stitch_details._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodStitchDetailsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_vod_stitch_details(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_vod_stitch_details_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_vod_stitch_details._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_vod_stitch_details_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodStitchDetailsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/vodSessions/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_vod_stitch_details(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/vodSessions/*}/vodStitchDetails" + % client.transport._host, + args[1], + ) + + +def test_list_vod_stitch_details_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_stitch_details( + video_stitcher_service.ListVodStitchDetailsRequest(), + parent="parent_value", + ) + + +def test_list_vod_stitch_details_rest_pager(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + next_page_token="abc", + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[], + next_page_token="def", + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + ], + next_page_token="ghi", + ), + video_stitcher_service.ListVodStitchDetailsResponse( + vod_stitch_details=[ + stitch_details.VodStitchDetail(), + stitch_details.VodStitchDetail(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + video_stitcher_service.ListVodStitchDetailsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/vodSessions/sample3" + } + + pager = client.list_vod_stitch_details(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, stitch_details.VodStitchDetail) for i in results) + + pages = list(client.list_vod_stitch_details(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_vod_stitch_detail_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_vod_stitch_detail + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_vod_stitch_detail + ] = mock_rpc + + request = {} + client.get_vod_stitch_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_stitch_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_stitch_detail_rest_required_fields( + request_type=video_stitcher_service.GetVodStitchDetailRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_stitch_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_stitch_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = stitch_details.VodStitchDetail() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = stitch_details.VodStitchDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_stitch_detail(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_vod_stitch_detail_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_vod_stitch_detail._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_vod_stitch_detail_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = stitch_details.VodStitchDetail() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = stitch_details.VodStitchDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_stitch_detail(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/vodSessions/*/vodStitchDetails/*}" + % client.transport._host, + args[1], + ) + + +def test_get_vod_stitch_detail_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_stitch_detail( + video_stitcher_service.GetVodStitchDetailRequest(), + name="name_value", + ) + + +def test_list_vod_ad_tag_details_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_vod_ad_tag_details + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_vod_ad_tag_details + ] = mock_rpc + + request = {} + client.list_vod_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_vod_ad_tag_details_rest_required_fields( + request_type=video_stitcher_service.ListVodAdTagDetailsRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_vod_ad_tag_details._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_vod_ad_tag_details._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_vod_ad_tag_details(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_vod_ad_tag_details_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_vod_ad_tag_details._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_vod_ad_tag_details_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/vodSessions/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_vod_ad_tag_details(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/vodSessions/*}/vodAdTagDetails" + % client.transport._host, + args[1], + ) + + +def test_list_vod_ad_tag_details_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_ad_tag_details( + video_stitcher_service.ListVodAdTagDetailsRequest(), + parent="parent_value", + ) + + +def test_list_vod_ad_tag_details_rest_pager(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + next_page_token="abc", + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[], + next_page_token="def", + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ], + next_page_token="ghi", + ), + video_stitcher_service.ListVodAdTagDetailsResponse( + vod_ad_tag_details=[ + ad_tag_details.VodAdTagDetail(), + ad_tag_details.VodAdTagDetail(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + video_stitcher_service.ListVodAdTagDetailsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/vodSessions/sample3" + } + + pager = client.list_vod_ad_tag_details(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, ad_tag_details.VodAdTagDetail) for i in results) + + pages = list(client.list_vod_ad_tag_details(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_vod_ad_tag_detail_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_vod_ad_tag_detail + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_vod_ad_tag_detail + ] = mock_rpc + + request = {} + client.get_vod_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_ad_tag_detail_rest_required_fields( + request_type=video_stitcher_service.GetVodAdTagDetailRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.VodAdTagDetail() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.VodAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_ad_tag_detail(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_vod_ad_tag_detail_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_vod_ad_tag_detail._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_vod_ad_tag_detail_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.VodAdTagDetail() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = ad_tag_details.VodAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_ad_tag_detail(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/vodSessions/*/vodAdTagDetails/*}" + % client.transport._host, + args[1], + ) + + +def test_get_vod_ad_tag_detail_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_ad_tag_detail( + video_stitcher_service.GetVodAdTagDetailRequest(), + name="name_value", + ) + + +def test_list_live_ad_tag_details_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.list_live_ad_tag_details + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_live_ad_tag_details + ] = mock_rpc + + request = {} + client.list_live_ad_tag_details(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_live_ad_tag_details(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_live_ad_tag_details_rest_required_fields( + request_type=video_stitcher_service.ListLiveAdTagDetailsRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_live_ad_tag_details._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_live_ad_tag_details._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_live_ad_tag_details(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_live_ad_tag_details_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_live_ad_tag_details._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_live_ad_tag_details_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = { + "parent": "projects/sample1/locations/sample2/liveSessions/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_live_ad_tag_details(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*/liveSessions/*}/liveAdTagDetails" + % client.transport._host, + args[1], + ) + + +def test_list_live_ad_tag_details_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_live_ad_tag_details( + video_stitcher_service.ListLiveAdTagDetailsRequest(), + parent="parent_value", + ) + + +def test_list_live_ad_tag_details_rest_pager(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token="abc", + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[], + next_page_token="def", + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ], + next_page_token="ghi", + ), + video_stitcher_service.ListLiveAdTagDetailsResponse( + live_ad_tag_details=[ + ad_tag_details.LiveAdTagDetail(), + ad_tag_details.LiveAdTagDetail(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + video_stitcher_service.ListLiveAdTagDetailsResponse.to_json(x) + for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = { + "parent": "projects/sample1/locations/sample2/liveSessions/sample3" + } + + pager = client.list_live_ad_tag_details(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, ad_tag_details.LiveAdTagDetail) for i in results) + + pages = list(client.list_live_ad_tag_details(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_live_ad_tag_detail_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.get_live_ad_tag_detail + in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_live_ad_tag_detail + ] = mock_rpc + + request = {} + client.get_live_ad_tag_detail(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_ad_tag_detail(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_live_ad_tag_detail_rest_required_fields( + request_type=video_stitcher_service.GetLiveAdTagDetailRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_live_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_live_ad_tag_detail._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.LiveAdTagDetail() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_live_ad_tag_detail(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_live_ad_tag_detail_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_live_ad_tag_detail._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_live_ad_tag_detail_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.LiveAdTagDetail() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_live_ad_tag_detail(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/liveSessions/*/liveAdTagDetails/*}" + % client.transport._host, + args[1], + ) + + +def test_get_live_ad_tag_detail_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_ad_tag_detail( + video_stitcher_service.GetLiveAdTagDetailRequest(), + name="name_value", + ) + + +def test_create_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.create_slate] = mock_rpc + + request = {} + client.create_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_slate_rest_required_fields( + request_type=video_stitcher_service.CreateSlateRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["slate_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "slateId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "slateId" in jsonified_request + assert jsonified_request["slateId"] == request_init["slate_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["slateId"] = "slate_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_slate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "request_id", + "slate_id", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "slateId" in jsonified_request + assert jsonified_request["slateId"] == "slate_id_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_slate(request) + + expected_params = [ + ( + "slateId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_slate._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "requestId", + "slateId", + ) + ) + & set( + ( + "parent", + "slateId", + "slate", + ) + ) + ) + + +def test_create_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + slate=slates.Slate(name="name_value"), + slate_id="slate_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/slates" % client.transport._host, + args[1], + ) + + +def test_create_slate_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_slate( + video_stitcher_service.CreateSlateRequest(), + parent="parent_value", + slate=slates.Slate(name="name_value"), + slate_id="slate_id_value", + ) + + +def test_list_slates_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_slates in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.list_slates] = mock_rpc + + request = {} + client.list_slates(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_slates(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_slates_rest_required_fields( + request_type=video_stitcher_service.ListSlatesRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_slates._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_slates._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListSlatesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_slates(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_slates_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_slates._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_slates_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListSlatesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_slates(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/slates" % client.transport._host, + args[1], + ) + + +def test_list_slates_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_slates( + video_stitcher_service.ListSlatesRequest(), + parent="parent_value", + ) + + +def test_list_slates_rest_pager(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + slates.Slate(), + ], + next_page_token="abc", + ), + video_stitcher_service.ListSlatesResponse( + slates=[], + next_page_token="def", + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + ], + next_page_token="ghi", + ), + video_stitcher_service.ListSlatesResponse( + slates=[ + slates.Slate(), + slates.Slate(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + video_stitcher_service.ListSlatesResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_slates(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, slates.Slate) for i in results) + + pages = list(client.list_slates(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_slate] = mock_rpc + + request = {} + client.get_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_slate_rest_required_fields( + request_type=video_stitcher_service.GetSlateRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = slates.Slate() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = slates.Slate.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_slate(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_slate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = slates.Slate() + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/slates/sample3"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = slates.Slate.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/slates/*}" % client.transport._host, + args[1], + ) + + +def test_get_slate_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_slate( + video_stitcher_service.GetSlateRequest(), + name="name_value", + ) + + +def test_update_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.update_slate] = mock_rpc + + request = {} + client.update_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_slate_rest_required_fields( + request_type=video_stitcher_service.UpdateSlateRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_slate._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_slate(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_slate._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "slate", + "updateMask", + ) + ) + ) + + +def test_update_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "slate": {"name": "projects/sample1/locations/sample2/slates/sample3"} + } + + # get truthy value for each flattened field + mock_args = dict( + slate=slates.Slate(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{slate.name=projects/*/locations/*/slates/*}" + % client.transport._host, + args[1], + ) + + +def test_update_slate_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_slate( + video_stitcher_service.UpdateSlateRequest(), + slate=slates.Slate(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_delete_slate_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_slate in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.delete_slate] = mock_rpc + + request = {} + client.delete_slate(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_slate(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_slate_rest_required_fields( + request_type=video_stitcher_service.DeleteSlateRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_slate._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_slate(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_slate_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_slate._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_slate_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"name": "projects/sample1/locations/sample2/slates/sample3"} + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_slate(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/slates/*}" % client.transport._host, + args[1], + ) + + +def test_delete_slate_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_slate( + video_stitcher_service.DeleteSlateRequest(), + name="name_value", + ) + + +def test_create_live_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_live_session in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_live_session + ] = mock_rpc + + request = {} + client.create_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.create_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_live_session_rest_required_fields( + request_type=video_stitcher_service.CreateLiveSessionRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_live_session(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_live_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_live_session._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(()) + & set( + ( + "parent", + "liveSession", + ) + ) + ) + + +def test_create_live_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + live_session=sessions.LiveSession(name="name_value"), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_live_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/liveSessions" + % client.transport._host, + args[1], + ) + + +def test_create_live_session_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_live_session( + video_stitcher_service.CreateLiveSessionRequest(), + parent="parent_value", + live_session=sessions.LiveSession(name="name_value"), + ) + + +def test_get_live_session_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_session in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.get_live_session + ] = mock_rpc + + request = {} + client.get_live_session(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_session(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_live_session_rest_required_fields( + request_type=video_stitcher_service.GetLiveSessionRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_live_session._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_live_session(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_live_session_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_live_session._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_live_session_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/liveSessions/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_live_session(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/liveSessions/*}" + % client.transport._host, + args[1], + ) + + +def test_get_live_session_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_session( + video_stitcher_service.GetLiveSessionRequest(), + name="name_value", + ) + + +def test_create_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.create_live_config in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_live_config + ] = mock_rpc + + request = {} + client.create_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_live_config_rest_required_fields( + request_type=video_stitcher_service.CreateLiveConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["live_config_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "liveConfigId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "liveConfigId" in jsonified_request + assert jsonified_request["liveConfigId"] == request_init["live_config_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["liveConfigId"] = "live_config_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_live_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "live_config_id", + "request_id", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "liveConfigId" in jsonified_request + assert jsonified_request["liveConfigId"] == "live_config_id_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_live_config(request) + + expected_params = [ + ( + "liveConfigId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_live_config._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "liveConfigId", + "requestId", + ) + ) + & set( + ( + "parent", + "liveConfigId", + "liveConfig", + ) + ) + ) + + +def test_create_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + live_config=live_configs.LiveConfig(name="name_value"), + live_config_id="live_config_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/liveConfigs" + % client.transport._host, + args[1], + ) + + +def test_create_live_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_live_config( + video_stitcher_service.CreateLiveConfigRequest(), + parent="parent_value", + live_config=live_configs.LiveConfig(name="name_value"), + live_config_id="live_config_id_value", + ) + + +def test_list_live_configs_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_live_configs in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_live_configs + ] = mock_rpc + + request = {} + client.list_live_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_live_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_live_configs_rest_required_fields( + request_type=video_stitcher_service.ListLiveConfigsRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_live_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_live_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveConfigsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveConfigsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_live_configs(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_live_configs_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_live_configs._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_live_configs_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveConfigsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_live_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/liveConfigs" + % client.transport._host, + args[1], + ) + + +def test_list_live_configs_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_live_configs( + video_stitcher_service.ListLiveConfigsRequest(), + parent="parent_value", + ) + + +def test_list_live_configs_rest_pager(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + next_page_token="abc", + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[], + next_page_token="def", + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + ], + next_page_token="ghi", + ), + video_stitcher_service.ListLiveConfigsResponse( + live_configs=[ + live_configs.LiveConfig(), + live_configs.LiveConfig(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + video_stitcher_service.ListLiveConfigsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_live_configs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, live_configs.LiveConfig) for i in results) + + pages = list(client.list_live_configs(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_live_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_live_config] = mock_rpc + + request = {} + client.get_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_live_config_rest_required_fields( + request_type=video_stitcher_service.GetLiveConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = live_configs.LiveConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = live_configs.LiveConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_live_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_live_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = live_configs.LiveConfig() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/liveConfigs/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = live_configs.LiveConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/liveConfigs/*}" + % client.transport._host, + args[1], + ) + + +def test_get_live_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_live_config( + video_stitcher_service.GetLiveConfigRequest(), + name="name_value", + ) + + +def test_delete_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.delete_live_config in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_live_config + ] = mock_rpc + + request = {} + client.delete_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_live_config_rest_required_fields( + request_type=video_stitcher_service.DeleteLiveConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_live_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_live_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/liveConfigs/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/liveConfigs/*}" + % client.transport._host, + args[1], + ) + + +def test_delete_live_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_live_config( + video_stitcher_service.DeleteLiveConfigRequest(), + name="name_value", + ) + + +def test_update_live_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert ( + client._transport.update_live_config in client._transport._wrapped_methods + ) + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_live_config + ] = mock_rpc + + request = {} + client.update_live_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_live_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_live_config_rest_required_fields( + request_type=video_stitcher_service.UpdateLiveConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_live_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_live_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_live_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_live_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_live_config._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "liveConfig", + "updateMask", + ) + ) + ) + + +def test_update_live_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "live_config": { + "name": "projects/sample1/locations/sample2/liveConfigs/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + live_config=live_configs.LiveConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_live_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{live_config.name=projects/*/locations/*/liveConfigs/*}" + % client.transport._host, + args[1], + ) + + +def test_update_live_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_live_config( + video_stitcher_service.UpdateLiveConfigRequest(), + live_config=live_configs.LiveConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_create_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.create_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.create_vod_config + ] = mock_rpc + + request = {} + client.create_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.create_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_create_vod_config_rest_required_fields( + request_type=video_stitcher_service.CreateVodConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["vod_config_id"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + assert "vodConfigId" not in jsonified_request + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + assert "vodConfigId" in jsonified_request + assert jsonified_request["vodConfigId"] == request_init["vod_config_id"] + + jsonified_request["parent"] = "parent_value" + jsonified_request["vodConfigId"] = "vod_config_id_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).create_vod_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "request_id", + "vod_config_id", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + assert "vodConfigId" in jsonified_request + assert jsonified_request["vodConfigId"] == "vod_config_id_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "post", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.create_vod_config(request) + + expected_params = [ + ( + "vodConfigId", + "", + ), + ("$alt", "json;enum-encoding=int"), + ] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_create_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.create_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "requestId", + "vodConfigId", + ) + ) + & set( + ( + "parent", + "vodConfigId", + "vodConfig", + ) + ) + ) + + +def test_create_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + vod_config=vod_configs.VodConfig(name="name_value"), + vod_config_id="vod_config_id_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.create_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/vodConfigs" % client.transport._host, + args[1], + ) + + +def test_create_vod_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_vod_config( + video_stitcher_service.CreateVodConfigRequest(), + parent="parent_value", + vod_config=vod_configs.VodConfig(name="name_value"), + vod_config_id="vod_config_id_value", + ) + + +def test_list_vod_configs_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.list_vod_configs in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.list_vod_configs + ] = mock_rpc + + request = {} + client.list_vod_configs(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.list_vod_configs(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_list_vod_configs_rest_required_fields( + request_type=video_stitcher_service.ListVodConfigsRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_vod_configs._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = "parent_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).list_vod_configs._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set( + ( + "filter", + "order_by", + "page_size", + "page_token", + ) + ) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == "parent_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodConfigsResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodConfigsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.list_vod_configs(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_list_vod_configs_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.list_vod_configs._get_unset_required_fields({}) + assert set(unset_fields) == ( + set( + ( + "filter", + "orderBy", + "pageSize", + "pageToken", + ) + ) + & set(("parent",)) + ) + + +def test_list_vod_configs_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodConfigsResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {"parent": "projects/sample1/locations/sample2"} + + # get truthy value for each flattened field + mock_args = dict( + parent="parent_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.list_vod_configs(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{parent=projects/*/locations/*}/vodConfigs" % client.transport._host, + args[1], + ) + + +def test_list_vod_configs_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_vod_configs( + video_stitcher_service.ListVodConfigsRequest(), + parent="parent_value", + ) + + +def test_list_vod_configs_rest_pager(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + # with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + next_page_token="abc", + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[], + next_page_token="def", + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + ], + next_page_token="ghi", + ), + video_stitcher_service.ListVodConfigsResponse( + vod_configs=[ + vod_configs.VodConfig(), + vod_configs.VodConfig(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple( + video_stitcher_service.ListVodConfigsResponse.to_json(x) for x in response + ) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode("UTF-8") + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {"parent": "projects/sample1/locations/sample2"} + + pager = client.list_vod_configs(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, vod_configs.VodConfig) for i in results) + + pages = list(client.list_vod_configs(request=sample_request).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +def test_get_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.get_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[client._transport.get_vod_config] = mock_rpc + + request = {} + client.get_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + client.get_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_get_vod_config_rest_required_fields( + request_type=video_stitcher_service.GetVodConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).get_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = vod_configs.VodConfig() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "get", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = vod_configs.VodConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.get_vod_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_get_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.get_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_get_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = vod_configs.VodConfig() + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/vodConfigs/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = vod_configs.VodConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.get_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, + args[1], + ) + + +def test_get_vod_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_vod_config( + video_stitcher_service.GetVodConfigRequest(), + name="name_value", + ) + + +def test_delete_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.delete_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.delete_vod_config + ] = mock_rpc + + request = {} + client.delete_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.delete_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_delete_vod_config_rest_required_fields( + request_type=video_stitcher_service.DeleteVodConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = "name_value" + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).delete_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == "name_value" + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "delete", + "query_params": pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.delete_vod_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_delete_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.delete_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name",))) + + +def test_delete_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "name": "projects/sample1/locations/sample2/vodConfigs/sample3" + } + + # get truthy value for each flattened field + mock_args = dict( + name="name_value", + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.delete_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{name=projects/*/locations/*/vodConfigs/*}" % client.transport._host, + args[1], + ) + + +def test_delete_vod_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_vod_config( + video_stitcher_service.DeleteVodConfigRequest(), + name="name_value", + ) + + +def test_update_vod_config_rest_use_cached_wrapped_rpc(): + # Clients should use _prep_wrapped_messages to create cached wrapped rpcs, + # instead of constructing them on each call + with mock.patch("google.api_core.gapic_v1.method.wrap_method") as wrapper_fn: + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Should wrap all calls on client creation + assert wrapper_fn.call_count > 0 + wrapper_fn.reset_mock() + + # Ensure method has been cached + assert client._transport.update_vod_config in client._transport._wrapped_methods + + # Replace cached wrapped function with mock + mock_rpc = mock.Mock() + mock_rpc.return_value.name = ( + "foo" # operation_request.operation in compute client(s) expect a string. + ) + client._transport._wrapped_methods[ + client._transport.update_vod_config + ] = mock_rpc + + request = {} + client.update_vod_config(request) + + # Establish that the underlying gRPC stub method was called. + assert mock_rpc.call_count == 1 + + # Operation methods build a cached wrapper on first rpc call + # subsequent calls should use the cached wrapper + wrapper_fn.reset_mock() + + client.update_vod_config(request) + + # Establish that a new wrapper was not created for this call + assert wrapper_fn.call_count == 0 + assert mock_rpc.call_count == 2 + + +def test_update_vod_config_rest_required_fields( + request_type=video_stitcher_service.UpdateVodConfigRequest, +): + transport_class = transports.VideoStitcherServiceRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads( + json_format.MessageToJson(pb_request, use_integers_for_enums=False) + ) + + # verify fields with default values are dropped + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_vod_config._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ).update_vod_config._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask",)) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, "transcode") as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + "uri": "v1/sample_method", + "method": "patch", + "query_params": pb_request, + } + transcode_result["body"] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + response = client.update_vod_config(request) + + expected_params = [("$alt", "json;enum-encoding=int")] + actual_params = req.call_args.kwargs["params"] + assert expected_params == actual_params + + +def test_update_vod_config_rest_unset_required_fields(): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials + ) + + unset_fields = transport.update_vod_config._get_unset_required_fields({}) + assert set(unset_fields) == ( + set(("updateMask",)) + & set( + ( + "vodConfig", + "updateMask", + ) + ) + ) + + +def test_update_vod_config_rest_flattened(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # get arguments that satisfy an http rule for this method + sample_request = { + "vod_config": { + "name": "projects/sample1/locations/sample2/vodConfigs/sample3" + } + } + + # get truthy value for each flattened field + mock_args = dict( + vod_config=vod_configs.VodConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + + client.update_vod_config(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate( + "%s/v1/{vod_config.name=projects/*/locations/*/vodConfigs/*}" + % client.transport._host, + args[1], + ) + + +def test_update_vod_config_rest_flattened_error(transport: str = "rest"): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_vod_config( + video_stitcher_service.UpdateVodConfigRequest(), + vod_config=vod_configs.VodConfig(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = VideoStitcherServiceClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = VideoStitcherServiceClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.VideoStitcherServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.VideoStitcherServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VideoStitcherServiceGrpcTransport, + transports.VideoStitcherServiceGrpcAsyncIOTransport, + transports.VideoStitcherServiceRestTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_kind_grpc(): + transport = VideoStitcherServiceClient.get_transport_class("grpc")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "grpc" + + +def test_initialize_client_w_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_cdn_key), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_cdn_keys_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_cdn_keys), "__call__") as call: + call.return_value = video_stitcher_service.ListCdnKeysResponse() + client.list_cdn_keys(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListCdnKeysRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_cdn_key), "__call__") as call: + call.return_value = cdn_keys.CdnKey() + client.get_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_cdn_key), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_cdn_key_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_cdn_key), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_vod_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), "__call__" + ) as call: + call.return_value = sessions.VodSession() + client.create_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_vod_session), "__call__") as call: + call.return_value = sessions.VodSession() + client.get_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_stitch_details_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), "__call__" + ) as call: + call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() + client.list_vod_stitch_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodStitchDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_stitch_detail_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), "__call__" + ) as call: + call.return_value = stitch_details.VodStitchDetail() + client.get_vod_stitch_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodStitchDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_ad_tag_details_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), "__call__" + ) as call: + call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + client.list_vod_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_ad_tag_detail_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), "__call__" + ) as call: + call.return_value = ad_tag_details.VodAdTagDetail() + client.get_vod_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_live_ad_tag_details_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), "__call__" + ) as call: + call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + client.list_live_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_ad_tag_detail_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), "__call__" + ) as call: + call.return_value = ad_tag_details.LiveAdTagDetail() + client.get_live_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_slate), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_slates_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_slates), "__call__") as call: + call.return_value = video_stitcher_service.ListSlatesResponse() + client.list_slates(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListSlatesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_slate), "__call__") as call: + call.return_value = slates.Slate() + client.get_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_slate), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_slate_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_slate), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_live_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), "__call__" + ) as call: + call.return_value = sessions.LiveSession() + client.create_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_session_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_live_session), "__call__") as call: + call.return_value = sessions.LiveSession() + client.get_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_live_configs_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), "__call__" + ) as call: + call.return_value = video_stitcher_service.ListLiveConfigsResponse() + client.list_live_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_live_config), "__call__") as call: + call.return_value = live_configs.LiveConfig() + client.get_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_live_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_create_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.create_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_list_vod_configs_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_vod_configs), "__call__") as call: + call.return_value = video_stitcher_service.ListVodConfigsResponse() + client.list_vod_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_get_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_vod_config), "__call__") as call: + call.return_value = vod_configs.VodConfig() + client.get_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_delete_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.delete_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +def test_update_vod_config_empty_call_grpc(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + client.update_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateVodConfigRequest() + + assert args[0] == request_msg + + +def test_transport_kind_grpc_asyncio(): + transport = VideoStitcherServiceAsyncClient.get_transport_class("grpc_asyncio")( + credentials=async_anonymous_credentials() + ) + assert transport.kind == "grpc_asyncio" + + +def test_initialize_client_w_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), transport="grpc_asyncio" + ) + assert client is not None + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_cdn_key), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_cdn_keys_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_cdn_keys), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + video_stitcher_service.ListCdnKeysResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_cdn_keys(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListCdnKeysRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_cdn_key), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cdn_keys.CdnKey( + name="name_value", + hostname="hostname_value", + ) + ) + await client.get_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_cdn_key), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_cdn_key_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_cdn_key), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_cdn_key(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateCdnKeyRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_vod_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_session), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + sessions.VodSession( + name="name_value", + play_uri="play_uri_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + asset_id="asset_id_value", + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config="vod_config_value", + ) + ) + await client.create_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_vod_session), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + sessions.VodSession( + name="name_value", + play_uri="play_uri_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + asset_id="asset_id_value", + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config="vod_config_value", + ) + ) + await client.get_vod_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_vod_stitch_details_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_stitch_details), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + video_stitcher_service.ListVodStitchDetailsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_vod_stitch_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodStitchDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_stitch_detail_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_stitch_detail), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + stitch_details.VodStitchDetail( + name="name_value", + ) + ) + await client.get_vod_stitch_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodStitchDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_vod_ad_tag_details_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_vod_ad_tag_details), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + video_stitcher_service.ListVodAdTagDetailsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_vod_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_ad_tag_detail_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_vod_ad_tag_detail), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + ad_tag_details.VodAdTagDetail( + name="name_value", + ) + ) + await client.get_vod_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_live_ad_tag_details_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_ad_tag_details), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + video_stitcher_service.ListLiveAdTagDetailsResponse( + next_page_token="next_page_token_value", + ) + ) + await client.list_live_ad_tag_details(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_live_ad_tag_detail_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.get_live_ad_tag_detail), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + ad_tag_details.LiveAdTagDetail( + name="name_value", + ) + ) + await client.get_live_ad_tag_detail(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.create_slate), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_slates_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_slates), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + video_stitcher_service.ListSlatesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_slates(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListSlatesRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_slate), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + slates.Slate( + name="name_value", + uri="uri_value", + ) + ) + await client.get_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.update_slate), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_slate_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.delete_slate), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_slate(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteSlateRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_live_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_session), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + sessions.LiveSession( + name="name_value", + play_uri="play_uri_value", + live_config="live_config_value", + ad_tracking=live_configs.AdTracking.CLIENT, + ) + ) + await client.create_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_live_session_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_live_session), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + sessions.LiveSession( + name="name_value", + play_uri="play_uri_value", + live_config="live_config_value", + ad_tracking=live_configs.AdTracking.CLIENT, + ) + ) + await client.get_live_session(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveSessionRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_live_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateLiveConfigRequest() + + assert args[0] == request_msg # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -def test_create_vod_session_empty_call_grpc(): +@pytest.mark.asyncio +async def test_list_live_configs_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.list_live_configs), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + video_stitcher_service.ListLiveConfigsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_live_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListLiveConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_live_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + live_configs.LiveConfig( + name="name_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + state=live_configs.LiveConfig.State.CREATING, + ad_tracking=live_configs.AdTracking.CLIENT, + default_slate="default_slate_value", + stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, + ) + ) + await client.get_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_live_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_live_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_live_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_live_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateLiveConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_create_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.create_vod_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.create_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.CreateVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_list_vod_configs_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.list_vod_configs), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + video_stitcher_service.ListVodConfigsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + ) + await client.list_vod_configs(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.ListVodConfigsRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_get_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_vod_config), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + vod_configs.VodConfig( + name="name_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + state=vod_configs.VodConfig.State.CREATING, + ) + ) + await client.get_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.GetVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_delete_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.delete_vod_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.delete_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.DeleteVodConfigRequest() + + assert args[0] == request_msg + + +# This test is a coverage failsafe to make sure that totally empty calls, +# i.e. request == None and no flattened fields passed, work. +@pytest.mark.asyncio +async def test_update_vod_config_empty_call_grpc_asyncio(): + client = VideoStitcherServiceAsyncClient( + credentials=async_anonymous_credentials(), + transport="grpc_asyncio", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object( + type(client.transport.update_vod_config), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/spam") + ) + await client.update_vod_config(request=None) + + # Establish that the underlying stub method was called. + call.assert_called() + _, args, _ = call.mock_calls[0] + request_msg = video_stitcher_service.UpdateVodConfigRequest() + + assert args[0] == request_msg + + +def test_transport_kind_rest(): + transport = VideoStitcherServiceClient.get_transport_class("rest")( + credentials=ga_credentials.AnonymousCredentials() + ) + assert transport.kind == "rest" + + +def test_create_cdn_key_rest_bad_request( + request_type=video_stitcher_service.CreateCdnKeyRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_cdn_key(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.CreateCdnKeyRequest, + dict, + ], +) +def test_create_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["cdn_key"] = { + "google_cdn_key": { + "private_key": b"private_key_blob", + "key_name": "key_name_value", + }, + "akamai_cdn_key": {"token_key": b"token_key_blob"}, + "media_cdn_key": { + "private_key": b"private_key_blob", + "key_name": "key_name_value", + "token_config": {"query_parameter": "query_parameter_value"}, + }, + "name": "name_value", + "hostname": "hostname_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateCdnKeyRequest.meta.fields["cdn_key"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["cdn_key"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["cdn_key"][field])): + del request_init["cdn_key"][field][i][subfield] + else: + del request_init["cdn_key"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_cdn_key(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_create_cdn_key" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_create_cdn_key_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_create_cdn_key" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateCdnKeyRequest.pb( + video_stitcher_service.CreateCdnKeyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateCdnKeyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_cdn_key( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_cdn_keys_rest_bad_request( + request_type=video_stitcher_service.ListCdnKeysRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_cdn_keys(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.ListCdnKeysRequest, + dict, + ], +) +def test_list_cdn_keys_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListCdnKeysResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListCdnKeysResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_cdn_keys(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCdnKeysPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_cdn_keys_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_cdn_keys" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_list_cdn_keys_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_list_cdn_keys" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListCdnKeysRequest.pb( + video_stitcher_service.ListCdnKeysRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListCdnKeysResponse.to_json( + video_stitcher_service.ListCdnKeysResponse() + ) + req.return_value.content = return_value + + request = video_stitcher_service.ListCdnKeysRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListCdnKeysResponse() + post_with_metadata.return_value = ( + video_stitcher_service.ListCdnKeysResponse(), + metadata, + ) + + client.list_cdn_keys( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_cdn_key_rest_bad_request( + request_type=video_stitcher_service.GetCdnKeyRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_cdn_key(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetCdnKeyRequest, + dict, + ], +) +def test_get_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = cdn_keys.CdnKey( + name="name_value", + hostname="hostname_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = cdn_keys.CdnKey.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_cdn_key(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, cdn_keys.CdnKey) + assert response.name == "name_value" + assert response.hostname == "hostname_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_cdn_key" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_cdn_key_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_cdn_key" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetCdnKeyRequest.pb( + video_stitcher_service.GetCdnKeyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = cdn_keys.CdnKey.to_json(cdn_keys.CdnKey()) + req.return_value.content = return_value + + request = video_stitcher_service.GetCdnKeyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = cdn_keys.CdnKey() + post_with_metadata.return_value = cdn_keys.CdnKey(), metadata + + client.get_cdn_key( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_cdn_key_rest_bad_request( + request_type=video_stitcher_service.DeleteCdnKeyRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_cdn_key(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.DeleteCdnKeyRequest, + dict, + ], +) +def test_delete_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_cdn_key(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_delete_cdn_key" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_delete_cdn_key_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_delete_cdn_key" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteCdnKeyRequest.pb( + video_stitcher_service.DeleteCdnKeyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.DeleteCdnKeyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_cdn_key( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_cdn_key_rest_bad_request( + request_type=video_stitcher_service.UpdateCdnKeyRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "cdn_key": {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_cdn_key(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.UpdateCdnKeyRequest, + dict, + ], +) +def test_update_cdn_key_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "cdn_key": {"name": "projects/sample1/locations/sample2/cdnKeys/sample3"} + } + request_init["cdn_key"] = { + "google_cdn_key": { + "private_key": b"private_key_blob", + "key_name": "key_name_value", + }, + "akamai_cdn_key": {"token_key": b"token_key_blob"}, + "media_cdn_key": { + "private_key": b"private_key_blob", + "key_name": "key_name_value", + "token_config": {"query_parameter": "query_parameter_value"}, + }, + "name": "projects/sample1/locations/sample2/cdnKeys/sample3", + "hostname": "hostname_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateCdnKeyRequest.meta.fields["cdn_key"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["cdn_key"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["cdn_key"][field])): + del request_init["cdn_key"][field][i][subfield] + else: + del request_init["cdn_key"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_cdn_key(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_cdn_key_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_update_cdn_key" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_update_cdn_key_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_update_cdn_key" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateCdnKeyRequest.pb( + video_stitcher_service.UpdateCdnKeyRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.UpdateCdnKeyRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_cdn_key( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_vod_session_rest_bad_request( + request_type=video_stitcher_service.CreateVodSessionRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_vod_session(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.CreateVodSessionRequest, + dict, + ], +) +def test_create_vod_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["vod_session"] = { + "name": "name_value", + "interstitials": { + "ad_breaks": [ + { + "progress_events": [ + { + "time_offset": {"seconds": 751, "nanos": 543}, + "events": [ + { + "type_": 1, + "uri": "uri_value", + "id": "id_value", + "offset": {}, + } + ], + } + ], + "ads": [ + { + "duration": {}, + "companion_ads": { + "display_requirement": 1, + "companions": [ + { + "iframe_ad_resource": {"uri": "uri_value"}, + "static_ad_resource": { + "uri": "uri_value", + "creative_type": "creative_type_value", + }, + "html_ad_resource": { + "html_source": "html_source_value" + }, + "api_framework": "api_framework_value", + "height_px": 960, + "width_px": 871, + "asset_height_px": 1599, + "expanded_height_px": 1896, + "asset_width_px": 1510, + "expanded_width_px": 1807, + "ad_slot_id": "ad_slot_id_value", + "events": {}, + } + ], + }, + "activity_events": {}, + } + ], + "end_time_offset": {}, + "start_time_offset": {}, + } + ], + "session_content": {"duration": {}}, + }, + "play_uri": "play_uri_value", + "source_uri": "source_uri_value", + "ad_tag_uri": "ad_tag_uri_value", + "ad_tag_macro_map": {}, + "manifest_options": { + "include_renditions": [{"bitrate_bps": 1167, "codecs": "codecs_value"}], + "bitrate_order": 1, + }, + "asset_id": "asset_id_value", + "ad_tracking": 1, + "gam_settings": { + "network_code": "network_code_value", + "stream_id": "stream_id_value", + }, + "vod_config": "vod_config_value", + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateVodSessionRequest.meta.fields[ + "vod_session" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["vod_session"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vod_session"][field])): + del request_init["vod_session"][field][i][subfield] + else: + del request_init["vod_session"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession( + name="name_value", + play_uri="play_uri_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + asset_id="asset_id_value", + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config="vod_config_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_vod_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == "name_value" + assert response.play_uri == "play_uri_value" + assert response.source_uri == "source_uri_value" + assert response.ad_tag_uri == "ad_tag_uri_value" + assert response.asset_id == "asset_id_value" + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == "vod_config_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_vod_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_create_vod_session" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_create_vod_session_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_create_vod_session" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateVodSessionRequest.pb( + video_stitcher_service.CreateVodSessionRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.VodSession.to_json(sessions.VodSession()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateVodSessionRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.VodSession() + post_with_metadata.return_value = sessions.VodSession(), metadata + + client.create_vod_session( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_vod_session_rest_bad_request( + request_type=video_stitcher_service.GetVodSessionRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/vodSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_session(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetVodSessionRequest, + dict, + ], +) +def test_get_vod_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/vodSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.VodSession( + name="name_value", + play_uri="play_uri_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + asset_id="asset_id_value", + ad_tracking=live_configs.AdTracking.CLIENT, + vod_config="vod_config_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.VodSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.VodSession) + assert response.name == "name_value" + assert response.play_uri == "play_uri_value" + assert response.source_uri == "source_uri_value" + assert response.ad_tag_uri == "ad_tag_uri_value" + assert response.asset_id == "asset_id_value" + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.vod_config == "vod_config_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_vod_session" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_get_vod_session_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_session" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodSessionRequest.pb( + video_stitcher_service.GetVodSessionRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.VodSession.to_json(sessions.VodSession()) + req.return_value.content = return_value + + request = video_stitcher_service.GetVodSessionRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.VodSession() + post_with_metadata.return_value = sessions.VodSession(), metadata + + client.get_vod_session( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_vod_stitch_details_rest_bad_request( + request_type=video_stitcher_service.ListVodStitchDetailsRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/vodSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_vod_stitch_details(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.ListVodStitchDetailsRequest, + dict, + ], +) +def test_list_vod_stitch_details_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/vodSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodStitchDetailsResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodStitchDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_vod_stitch_details(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodStitchDetailsPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_vod_stitch_details_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_vod_stitch_details" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_list_vod_stitch_details_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_stitch_details" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListVodStitchDetailsRequest.pb( + video_stitcher_service.ListVodStitchDetailsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListVodStitchDetailsResponse.to_json( + video_stitcher_service.ListVodStitchDetailsResponse() + ) + req.return_value.content = return_value + + request = video_stitcher_service.ListVodStitchDetailsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListVodStitchDetailsResponse() + post_with_metadata.return_value = ( + video_stitcher_service.ListVodStitchDetailsResponse(), + metadata, + ) + + client.list_vod_stitch_details( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_vod_stitch_detail_rest_bad_request( + request_type=video_stitcher_service.GetVodStitchDetailRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_stitch_detail(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetVodStitchDetailRequest, + dict, + ], +) +def test_get_vod_stitch_detail_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/vodSessions/sample3/vodStitchDetails/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = stitch_details.VodStitchDetail( + name="name_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = stitch_details.VodStitchDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_stitch_detail(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, stitch_details.VodStitchDetail) + assert response.name == "name_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_stitch_detail_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_vod_stitch_detail" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_get_vod_stitch_detail_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_stitch_detail" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodStitchDetailRequest.pb( + video_stitcher_service.GetVodStitchDetailRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = stitch_details.VodStitchDetail.to_json( + stitch_details.VodStitchDetail() + ) + req.return_value.content = return_value + + request = video_stitcher_service.GetVodStitchDetailRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = stitch_details.VodStitchDetail() + post_with_metadata.return_value = stitch_details.VodStitchDetail(), metadata + + client.get_vod_stitch_detail( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_vod_ad_tag_details_rest_bad_request( + request_type=video_stitcher_service.ListVodAdTagDetailsRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/vodSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_vod_ad_tag_details(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.ListVodAdTagDetailsRequest, + dict, + ], +) +def test_list_vod_ad_tag_details_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/vodSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodAdTagDetailsResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_vod_ad_tag_details(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodAdTagDetailsPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_vod_ad_tag_details_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_vod_ad_tag_details" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_list_vod_ad_tag_details_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_ad_tag_details" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListVodAdTagDetailsRequest.pb( + video_stitcher_service.ListVodAdTagDetailsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListVodAdTagDetailsResponse.to_json( + video_stitcher_service.ListVodAdTagDetailsResponse() + ) + req.return_value.content = return_value + + request = video_stitcher_service.ListVodAdTagDetailsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() + post_with_metadata.return_value = ( + video_stitcher_service.ListVodAdTagDetailsResponse(), + metadata, + ) + + client.list_vod_ad_tag_details( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_vod_ad_tag_detail_rest_bad_request( + request_type=video_stitcher_service.GetVodAdTagDetailRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_ad_tag_detail(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetVodAdTagDetailRequest, + dict, + ], +) +def test_get_vod_ad_tag_detail_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/vodSessions/sample3/vodAdTagDetails/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.VodAdTagDetail( + name="name_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.VodAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_ad_tag_detail(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.VodAdTagDetail) + assert response.name == "name_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_ad_tag_detail_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_vod_ad_tag_detail" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_get_vod_ad_tag_detail_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_ad_tag_detail" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodAdTagDetailRequest.pb( + video_stitcher_service.GetVodAdTagDetailRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = ad_tag_details.VodAdTagDetail.to_json( + ad_tag_details.VodAdTagDetail() + ) + req.return_value.content = return_value + + request = video_stitcher_service.GetVodAdTagDetailRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = ad_tag_details.VodAdTagDetail() + post_with_metadata.return_value = ad_tag_details.VodAdTagDetail(), metadata + + client.get_vod_ad_tag_detail( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_live_ad_tag_details_rest_bad_request( + request_type=video_stitcher_service.ListLiveAdTagDetailsRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/liveSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_live_ad_tag_details(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.ListLiveAdTagDetailsRequest, + dict, + ], +) +def test_list_live_ad_tag_details_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2/liveSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse( + next_page_token="next_page_token_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.pb( + return_value + ) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_live_ad_tag_details(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveAdTagDetailsPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_live_ad_tag_details_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_live_ad_tag_details" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_list_live_ad_tag_details_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_list_live_ad_tag_details" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListLiveAdTagDetailsRequest.pb( + video_stitcher_service.ListLiveAdTagDetailsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListLiveAdTagDetailsResponse.to_json( + video_stitcher_service.ListLiveAdTagDetailsResponse() + ) + req.return_value.content = return_value + + request = video_stitcher_service.ListLiveAdTagDetailsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() + post_with_metadata.return_value = ( + video_stitcher_service.ListLiveAdTagDetailsResponse(), + metadata, + ) + + client.list_live_ad_tag_details( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_live_ad_tag_detail_rest_bad_request( + request_type=video_stitcher_service.GetLiveAdTagDetailRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_live_ad_tag_detail(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetLiveAdTagDetailRequest, + dict, + ], +) +def test_get_live_ad_tag_detail_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "name": "projects/sample1/locations/sample2/liveSessions/sample3/liveAdTagDetails/sample4" + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = ad_tag_details.LiveAdTagDetail( + name="name_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = ad_tag_details.LiveAdTagDetail.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_live_ad_tag_detail(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, ad_tag_details.LiveAdTagDetail) + assert response.name == "name_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_live_ad_tag_detail_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_live_ad_tag_detail" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_get_live_ad_tag_detail_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_live_ad_tag_detail" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetLiveAdTagDetailRequest.pb( + video_stitcher_service.GetLiveAdTagDetailRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = ad_tag_details.LiveAdTagDetail.to_json( + ad_tag_details.LiveAdTagDetail() + ) + req.return_value.content = return_value + + request = video_stitcher_service.GetLiveAdTagDetailRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = ad_tag_details.LiveAdTagDetail() + post_with_metadata.return_value = ad_tag_details.LiveAdTagDetail(), metadata + + client.get_live_ad_tag_detail( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_slate_rest_bad_request( + request_type=video_stitcher_service.CreateSlateRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_slate(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.CreateSlateRequest, + dict, + ], +) +def test_create_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["slate"] = { + "name": "name_value", + "uri": "uri_value", + "gam_slate": {"network_code": "network_code_value", "gam_slate_id": 1241}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateSlateRequest.meta.fields["slate"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["slate"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["slate"][field])): + del request_init["slate"][field][i][subfield] + else: + del request_init["slate"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_slate(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_create_slate" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_create_slate_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_create_slate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateSlateRequest.pb( + video_stitcher_service.CreateSlateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateSlateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_slate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_slates_rest_bad_request( + request_type=video_stitcher_service.ListSlatesRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_slates(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.ListSlatesRequest, + dict, + ], +) +def test_list_slates_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListSlatesResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListSlatesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_slates(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSlatesPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_slates_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_slates" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_slates_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_list_slates" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListSlatesRequest.pb( + video_stitcher_service.ListSlatesRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListSlatesResponse.to_json( + video_stitcher_service.ListSlatesResponse() + ) + req.return_value.content = return_value + + request = video_stitcher_service.ListSlatesRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListSlatesResponse() + post_with_metadata.return_value = ( + video_stitcher_service.ListSlatesResponse(), + metadata, + ) + + client.list_slates( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_slate_rest_bad_request( + request_type=video_stitcher_service.GetSlateRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/slates/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_slate(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetSlateRequest, + dict, + ], +) +def test_get_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/slates/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = slates.Slate( + name="name_value", + uri="uri_value", + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = slates.Slate.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_slate(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, slates.Slate) + assert response.name == "name_value" + assert response.uri == "uri_value" + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_slate" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_slate_with_metadata" + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_slate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetSlateRequest.pb( + video_stitcher_service.GetSlateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = slates.Slate.to_json(slates.Slate()) + req.return_value.content = return_value + + request = video_stitcher_service.GetSlateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = slates.Slate() + post_with_metadata.return_value = slates.Slate(), metadata + + client.get_slate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_update_slate_rest_bad_request( + request_type=video_stitcher_service.UpdateSlateRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "slate": {"name": "projects/sample1/locations/sample2/slates/sample3"} + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_slate(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.UpdateSlateRequest, + dict, + ], +) +def test_update_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "slate": {"name": "projects/sample1/locations/sample2/slates/sample3"} + } + request_init["slate"] = { + "name": "projects/sample1/locations/sample2/slates/sample3", + "uri": "uri_value", + "gam_slate": {"network_code": "network_code_value", "gam_slate_id": 1241}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateSlateRequest.meta.fields["slate"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["slate"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["slate"][field])): + del request_init["slate"][field][i][subfield] + else: + del request_init["slate"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_slate(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_update_slate" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_update_slate_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_update_slate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateSlateRequest.pb( + video_stitcher_service.UpdateSlateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.UpdateSlateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_slate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_delete_slate_rest_bad_request( + request_type=video_stitcher_service.DeleteSlateRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/slates/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_slate(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.DeleteSlateRequest, + dict, + ], +) +def test_delete_slate_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/slates/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_slate(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_slate_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_delete_slate" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_delete_slate_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_delete_slate" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteSlateRequest.pb( + video_stitcher_service.DeleteSlateRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.DeleteSlateRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.delete_slate( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_live_session_rest_bad_request( + request_type=video_stitcher_service.CreateLiveSessionRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_live_session(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.CreateLiveSessionRequest, + dict, + ], +) +def test_create_live_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["live_session"] = { + "name": "name_value", + "play_uri": "play_uri_value", + "ad_tag_macros": {}, + "manifest_options": { + "include_renditions": [{"bitrate_bps": 1167, "codecs": "codecs_value"}], + "bitrate_order": 1, + }, + "gam_settings": {"stream_id": "stream_id_value", "targeting_parameters": {}}, + "live_config": "live_config_value", + "ad_tracking": 1, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateLiveSessionRequest.meta.fields[ + "live_session" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["live_session"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["live_session"][field])): + del request_init["live_session"][field][i][subfield] + else: + del request_init["live_session"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession( + name="name_value", + play_uri="play_uri_value", + live_config="live_config_value", + ad_tracking=live_configs.AdTracking.CLIENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_live_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == "name_value" + assert response.play_uri == "play_uri_value" + assert response.live_config == "live_config_value" + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_live_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_create_live_session" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_create_live_session_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_create_live_session" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateLiveSessionRequest.pb( + video_stitcher_service.CreateLiveSessionRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.LiveSession.to_json(sessions.LiveSession()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateLiveSessionRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.LiveSession() + post_with_metadata.return_value = sessions.LiveSession(), metadata + + client.create_live_session( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_get_live_session_rest_bad_request( + request_type=video_stitcher_service.GetLiveSessionRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/liveSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_live_session(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetLiveSessionRequest, + dict, + ], +) +def test_get_live_session_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/liveSessions/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = sessions.LiveSession( + name="name_value", + play_uri="play_uri_value", + live_config="live_config_value", + ad_tracking=live_configs.AdTracking.CLIENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = sessions.LiveSession.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_live_session(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, sessions.LiveSession) + assert response.name == "name_value" + assert response.play_uri == "play_uri_value" + assert response.live_config == "live_config_value" + assert response.ad_tracking == live_configs.AdTracking.CLIENT + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_live_session_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_live_session" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_get_live_session_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_live_session" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetLiveSessionRequest.pb( + video_stitcher_service.GetLiveSessionRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = sessions.LiveSession.to_json(sessions.LiveSession()) + req.return_value.content = return_value + + request = video_stitcher_service.GetLiveSessionRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = sessions.LiveSession() + post_with_metadata.return_value = sessions.LiveSession(), metadata + + client.get_live_session( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_live_config_rest_bad_request( + request_type=video_stitcher_service.CreateLiveConfigRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_live_config(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.CreateLiveConfigRequest, + dict, + ], +) +def test_create_live_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["live_config"] = { + "name": "name_value", + "source_uri": "source_uri_value", + "ad_tag_uri": "ad_tag_uri_value", + "gam_live_config": { + "network_code": "network_code_value", + "asset_key": "asset_key_value", + "custom_asset_key": "custom_asset_key_value", + }, + "state": 1, + "ad_tracking": 1, + "default_slate": "default_slate_value", + "stitching_policy": 1, + "prefetch_config": { + "enabled": True, + "initial_ad_request_duration": {"seconds": 751, "nanos": 543}, + }, + "source_fetch_options": {"headers": {}}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateLiveConfigRequest.meta.fields[ + "live_config" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["live_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["live_config"][field])): + del request_init["live_config"][field][i][subfield] + else: + del request_init["live_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_live_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), + ) + client = VideoStitcherServiceClient(transport=transport) + + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_create_live_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_create_live_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_create_live_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateLiveConfigRequest.pb( + video_stitcher_service.CreateLiveConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.CreateLiveConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.create_live_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_list_live_configs_rest_bad_request( + request_type=video_stitcher_service.ListLiveConfigsRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_live_configs(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.ListLiveConfigsRequest, + dict, + ], +) +def test_list_live_configs_rest_call_success(request_type): client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListLiveConfigsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = video_stitcher_service.ListLiveConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_live_configs(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListLiveConfigsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_live_configs_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_vod_session), "__call__" - ) as call: - call.return_value = sessions.VodSession() - client.create_vod_session(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_live_configs" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_list_live_configs_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_list_live_configs" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListLiveConfigsRequest.pb( + video_stitcher_service.ListLiveConfigsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListLiveConfigsResponse.to_json( + video_stitcher_service.ListLiveConfigsResponse() + ) + req.return_value.content = return_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodSessionRequest() + request = video_stitcher_service.ListLiveConfigsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListLiveConfigsResponse() + post_with_metadata.return_value = ( + video_stitcher_service.ListLiveConfigsResponse(), + metadata, + ) - assert args[0] == request_msg + client.list_live_configs( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_session_empty_call_grpc(): + +def test_get_live_config_rest_bad_request( + request_type=video_stitcher_service.GetLiveConfigRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/liveConfigs/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_live_config(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetLiveConfigRequest, + dict, + ], +) +def test_get_live_config_rest_call_success(request_type): client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/liveConfigs/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = live_configs.LiveConfig( + name="name_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + state=live_configs.LiveConfig.State.CREATING, + ad_tracking=live_configs.AdTracking.CLIENT, + default_slate="default_slate_value", + stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, + ) + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = live_configs.LiveConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_live_config(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, live_configs.LiveConfig) + assert response.name == "name_value" + assert response.source_uri == "source_uri_value" + assert response.ad_tag_uri == "ad_tag_uri_value" + assert response.state == live_configs.LiveConfig.State.CREATING + assert response.ad_tracking == live_configs.AdTracking.CLIENT + assert response.default_slate == "default_slate_value" + assert ( + response.stitching_policy == live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT + ) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_vod_session), "__call__") as call: - call.return_value = sessions.VodSession() - client.get_vod_session(request=None) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_live_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_get_live_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_live_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetLiveConfigRequest.pb( + video_stitcher_service.GetLiveConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = live_configs.LiveConfig.to_json(live_configs.LiveConfig()) + req.return_value.content = return_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodSessionRequest() + request = video_stitcher_service.GetLiveConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = live_configs.LiveConfig() + post_with_metadata.return_value = live_configs.LiveConfig(), metadata - assert args[0] == request_msg + client.get_live_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_stitch_details_empty_call_grpc(): + +def test_delete_live_config_rest_bad_request( + request_type=video_stitcher_service.DeleteLiveConfigRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/liveConfigs/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_live_config(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.DeleteLiveConfigRequest, + dict, + ], +) +def test_delete_live_config_rest_call_success(request_type): client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/liveConfigs/sample3"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_live_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_vod_stitch_details), "__call__" - ) as call: - call.return_value = video_stitcher_service.ListVodStitchDetailsResponse() - client.list_vod_stitch_details(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_delete_live_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_delete_live_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_delete_live_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteLiveConfigRequest.pb( + video_stitcher_service.DeleteLiveConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodStitchDetailsRequest() + request = video_stitcher_service.DeleteLiveConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - assert args[0] == request_msg + client.delete_live_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_stitch_detail_empty_call_grpc(): + +def test_update_live_config_rest_bad_request( + request_type=video_stitcher_service.UpdateLiveConfigRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "live_config": { + "name": "projects/sample1/locations/sample2/liveConfigs/sample3" + } + } + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_live_config(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.UpdateLiveConfigRequest, + dict, + ], +) +def test_update_live_config_rest_call_success(request_type): client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = { + "live_config": { + "name": "projects/sample1/locations/sample2/liveConfigs/sample3" + } + } + request_init["live_config"] = { + "name": "projects/sample1/locations/sample2/liveConfigs/sample3", + "source_uri": "source_uri_value", + "ad_tag_uri": "ad_tag_uri_value", + "gam_live_config": { + "network_code": "network_code_value", + "asset_key": "asset_key_value", + "custom_asset_key": "custom_asset_key_value", + }, + "state": 1, + "ad_tracking": 1, + "default_slate": "default_slate_value", + "stitching_policy": 1, + "prefetch_config": { + "enabled": True, + "initial_ad_request_duration": {"seconds": 751, "nanos": 543}, + }, + "source_fetch_options": {"headers": {}}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateLiveConfigRequest.meta.fields[ + "live_config" + ] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["live_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["live_config"][field])): + del request_init["live_config"][field][i][subfield] + else: + del request_init["live_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_live_config(request) + + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_live_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_vod_stitch_detail), "__call__" - ) as call: - call.return_value = stitch_details.VodStitchDetail() - client.get_vod_stitch_detail(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_update_live_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_update_live_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_update_live_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateLiveConfigRequest.pb( + video_stitcher_service.UpdateLiveConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value + + request = video_stitcher_service.UpdateLiveConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + + client.update_live_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() + + +def test_create_vod_config_rest_bad_request( + request_type=video_stitcher_service.CreateVodConfigRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.create_vod_config(request) + + +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.CreateVodConfigRequest, + dict, + ], +) +def test_create_vod_config_rest_call_success(request_type): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request_init["vod_config"] = { + "name": "name_value", + "source_uri": "source_uri_value", + "ad_tag_uri": "ad_tag_uri_value", + "gam_vod_config": {"network_code": "network_code_value"}, + "state": 1, + "source_fetch_options": {"headers": {}}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.CreateVodConfigRequest.meta.fields["vod_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["vod_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodStitchDetailRequest() + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vod_config"][field])): + del request_init["vod_config"][field][i][subfield] + else: + del request_init["vod_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.create_vod_config(request) - assert args[0] == request_msg + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_ad_tag_details_empty_call_grpc(): - client = VideoStitcherServiceClient( +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_vod_ad_tag_details), "__call__" - ) as call: - call.return_value = video_stitcher_service.ListVodAdTagDetailsResponse() - client.list_vod_ad_tag_details(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_create_vod_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_create_vod_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_create_vod_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.CreateVodConfigRequest.pb( + video_stitcher_service.CreateVodConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodAdTagDetailsRequest() + request = video_stitcher_service.CreateVodConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - assert args[0] == request_msg + client.create_vod_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_ad_tag_detail_empty_call_grpc(): + +def test_list_vod_configs_rest_bad_request( + request_type=video_stitcher_service.ListVodConfigsRequest, +): client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.get_vod_ad_tag_detail), "__call__" - ) as call: - call.return_value = ad_tag_details.VodAdTagDetail() - client.get_vod_ad_tag_detail(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodAdTagDetailRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_vod_configs(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_live_ad_tag_details_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.ListVodConfigsRequest, + dict, + ], +) +def test_list_vod_configs_rest_call_success(request_type): client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.list_live_ad_tag_details), "__call__" - ) as call: - call.return_value = video_stitcher_service.ListLiveAdTagDetailsResponse() - client.list_live_ad_tag_details(request=None) + # send a request that will satisfy transcoding + request_init = {"parent": "projects/sample1/locations/sample2"} + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveAdTagDetailsRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = video_stitcher_service.ListVodConfigsResponse( + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], + ) - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = video_stitcher_service.ListVodConfigsResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_vod_configs(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_ad_tag_detail_empty_call_grpc(): - client = VideoStitcherServiceClient( + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListVodConfigsPager) + assert response.next_page_token == "next_page_token_value" + assert response.unreachable == ["unreachable_value"] + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_vod_configs_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.get_live_ad_tag_detail), "__call__" - ) as call: - call.return_value = ad_tag_details.LiveAdTagDetail() - client.get_live_ad_tag_detail(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_list_vod_configs" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_list_vod_configs_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_list_vod_configs" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.ListVodConfigsRequest.pb( + video_stitcher_service.ListVodConfigsRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = video_stitcher_service.ListVodConfigsResponse.to_json( + video_stitcher_service.ListVodConfigsResponse() + ) + req.return_value.content = return_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveAdTagDetailRequest() + request = video_stitcher_service.ListVodConfigsRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = video_stitcher_service.ListVodConfigsResponse() + post_with_metadata.return_value = ( + video_stitcher_service.ListVodConfigsResponse(), + metadata, + ) - assert args[0] == request_msg + client.list_vod_configs( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_slate_empty_call_grpc(): + +def test_get_vod_config_rest_bad_request( + request_type=video_stitcher_service.GetVodConfigRequest, +): client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/vodConfigs/sample3"} + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.create_slate), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateSlateRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_vod_config(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_slates_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.GetVodConfigRequest, + dict, + ], +) +def test_get_vod_config_rest_call_success(request_type): client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_slates), "__call__") as call: - call.return_value = video_stitcher_service.ListSlatesResponse() - client.list_slates(request=None) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/vodConfigs/sample3"} + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListSlatesRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = vod_configs.VodConfig( + name="name_value", + source_uri="source_uri_value", + ad_tag_uri="ad_tag_uri_value", + state=vod_configs.VodConfig.State.CREATING, + ) - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = vod_configs.VodConfig.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_vod_config(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_slate_empty_call_grpc(): - client = VideoStitcherServiceClient( + # Establish that the response is the type that we expect. + assert isinstance(response, vod_configs.VodConfig) + assert response.name == "name_value" + assert response.source_uri == "source_uri_value" + assert response.ad_tag_uri == "ad_tag_uri_value" + assert response.state == vod_configs.VodConfig.State.CREATING + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_slate), "__call__") as call: - call.return_value = slates.Slate() - client.get_slate(request=None) + with mock.patch.object( + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_get_vod_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_get_vod_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_get_vod_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.GetVodConfigRequest.pb( + video_stitcher_service.GetVodConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = vod_configs.VodConfig.to_json(vod_configs.VodConfig()) + req.return_value.content = return_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetSlateRequest() + request = video_stitcher_service.GetVodConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = vod_configs.VodConfig() + post_with_metadata.return_value = vod_configs.VodConfig(), metadata - assert args[0] == request_msg + client.get_vod_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_slate_empty_call_grpc(): + +def test_delete_vod_config_rest_bad_request( + request_type=video_stitcher_service.DeleteVodConfigRequest, +): client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/vodConfigs/sample3"} + request = request_type(**request_init) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.update_slate), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_slate(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateSlateRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_vod_config(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_slate_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.DeleteVodConfigRequest, + dict, + ], +) +def test_delete_vod_config_rest_call_success(request_type): client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.delete_slate), "__call__") as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_slate(request=None) + # send a request that will satisfy transcoding + request_init = {"name": "projects/sample1/locations/sample2/vodConfigs/sample3"} + request = request_type(**request_init) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteSlateRequest() + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") - assert args[0] == request_msg + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_vod_config(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_live_session_empty_call_grpc(): - client = VideoStitcherServiceClient( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.create_live_session), "__call__" - ) as call: - call.return_value = sessions.LiveSession() - client.create_live_session(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveSessionRequest() + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_delete_vod_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_delete_vod_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_delete_vod_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.DeleteVodConfigRequest.pb( + video_stitcher_service.DeleteVodConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - assert args[0] == request_msg + request = video_stitcher_service.DeleteVodConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata + client.delete_vod_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_session_empty_call_grpc(): - client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_live_session), "__call__") as call: - call.return_value = sessions.LiveSession() - client.get_live_session(request=None) - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveSessionRequest() +def test_update_vod_config_rest_bad_request( + request_type=video_stitcher_service.UpdateVodConfigRequest, +): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + # send a request that will satisfy transcoding + request_init = { + "vod_config": {"name": "projects/sample1/locations/sample2/vodConfigs/sample3"} + } + request = request_type(**request_init) - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = mock.Mock() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = mock.Mock() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.update_vod_config(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_live_config_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + video_stitcher_service.UpdateVodConfigRequest, + dict, + ], +) +def test_update_vod_config_rest_call_success(request_type): client = VideoStitcherServiceClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_live_config), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_live_config(request=None) + # send a request that will satisfy transcoding + request_init = { + "vod_config": {"name": "projects/sample1/locations/sample2/vodConfigs/sample3"} + } + request_init["vod_config"] = { + "name": "projects/sample1/locations/sample2/vodConfigs/sample3", + "source_uri": "source_uri_value", + "ad_tag_uri": "ad_tag_uri_value", + "gam_vod_config": {"network_code": "network_code_value"}, + "state": 1, + "source_fetch_options": {"headers": {}}, + } + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = video_stitcher_service.UpdateVodConfigRequest.meta.fields["vod_config"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateLiveConfigRequest() + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["vod_config"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + { + "field": field, + "subfield": subfield, + "is_repeated": is_repeated, + } + ) - assert args[0] == request_msg + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["vod_config"][field])): + del request_init["vod_config"][field][i][subfield] + else: + del request_init["vod_config"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation(name="operations/spam") + + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.update_vod_config(request) + # Establish that the response is the type that we expect. + json_return_value = json_format.MessageToJson(return_value) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_live_configs_empty_call_grpc(): - client = VideoStitcherServiceClient( + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_vod_config_rest_interceptors(null_interceptor): + transport = transports.VideoStitcherServiceRestTransport( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + interceptor=None + if null_interceptor + else transports.VideoStitcherServiceRestInterceptor(), ) + client = VideoStitcherServiceClient(transport=transport) - # Mock the actual call, and fake the request. with mock.patch.object( - type(client.transport.list_live_configs), "__call__" - ) as call: - call.return_value = video_stitcher_service.ListLiveConfigsResponse() - client.list_live_configs(request=None) + type(client.transport._session), "request" + ) as req, mock.patch.object( + path_template, "transcode" + ) as transcode, mock.patch.object( + operation.Operation, "_set_result_from_operation" + ), mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "post_update_vod_config" + ) as post, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, + "post_update_vod_config_with_metadata", + ) as post_with_metadata, mock.patch.object( + transports.VideoStitcherServiceRestInterceptor, "pre_update_vod_config" + ) as pre: + pre.assert_not_called() + post.assert_not_called() + post_with_metadata.assert_not_called() + pb_message = video_stitcher_service.UpdateVodConfigRequest.pb( + video_stitcher_service.UpdateVodConfigRequest() + ) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = mock.Mock() + req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + return_value = json_format.MessageToJson(operations_pb2.Operation()) + req.return_value.content = return_value - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListLiveConfigsRequest() + request = video_stitcher_service.UpdateVodConfigRequest() + metadata = [ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = operations_pb2.Operation() + post_with_metadata.return_value = operations_pb2.Operation(), metadata - assert args[0] == request_msg + client.update_vod_config( + request, + metadata=[ + ("key", "val"), + ("cephalopod", "squid"), + ], + ) + pre.assert_called_once() + post.assert_called_once() + post_with_metadata.assert_called_once() -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_live_config_empty_call_grpc(): + +def test_cancel_operation_rest_bad_request( + request_type=operations_pb2.CancelOperationRequest, +): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_live_config), "__call__") as call: - call.return_value = live_configs.LiveConfig() - client.get_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetLiveConfigRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.cancel_operation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_live_config_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.CancelOperationRequest, + dict, + ], +) +def test_cancel_operation_rest(request_type): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_live_config), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_live_config(request=None) + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = None - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteLiveConfigRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "{}" + response_value.content = json_return_value.encode("UTF-8") - assert args[0] == request_msg + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.cancel_operation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_live_config_empty_call_grpc(): + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_operation_rest_bad_request( + request_type=operations_pb2.DeleteOperationRequest, +): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_live_config), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_live_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateLiveConfigRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.delete_operation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_create_vod_config_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.DeleteOperationRequest, + dict, + ], +) +def test_delete_operation_rest(request_type): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.create_vod_config), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.create_vod_config(request=None) + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = None - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.CreateVodConfigRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = "{}" + response_value.content = json_return_value.encode("UTF-8") - assert args[0] == request_msg + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.delete_operation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_list_vod_configs_empty_call_grpc(): + # Establish that the response is the type that we expect. + assert response is None + + +def test_get_operation_rest_bad_request( + request_type=operations_pb2.GetOperationRequest, +): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2/operations/sample3"}, request ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.list_vod_configs), "__call__") as call: - call.return_value = video_stitcher_service.ListVodConfigsResponse() - client.list_vod_configs(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.ListVodConfigsRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.get_operation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_get_vod_config_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.GetOperationRequest, + dict, + ], +) +def test_get_operation_rest(request_type): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_vod_config), "__call__") as call: - call.return_value = vod_configs.VodConfig() - client.get_vod_config(request=None) + request_init = {"name": "projects/sample1/locations/sample2/operations/sample3"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.Operation() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.GetVodConfigRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") - assert args[0] == request_msg + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.get_operation(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_delete_vod_config_empty_call_grpc(): + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.Operation) + + +def test_list_operations_rest_bad_request( + request_type=operations_pb2.ListOperationsRequest, +): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", + ) + request = request_type() + request = json_format.ParseDict( + {"name": "projects/sample1/locations/sample2"}, request ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.delete_vod_config), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_vod_config(request=None) - - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.DeleteVodConfigRequest() - - assert args[0] == request_msg + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, "request") as req, pytest.raises( + core_exceptions.BadRequest + ): + # Wrap the value into a proper Response obj + response_value = Response() + json_return_value = "" + response_value.json = mock.Mock(return_value={}) + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + client.list_operations(request) -# This test is a coverage failsafe to make sure that totally empty calls, -# i.e. request == None and no flattened fields passed, work. -def test_update_vod_config_empty_call_grpc(): +@pytest.mark.parametrize( + "request_type", + [ + operations_pb2.ListOperationsRequest, + dict, + ], +) +def test_list_operations_rest(request_type): client = VideoStitcherServiceClient( credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", + transport="rest", ) - # Mock the actual call, and fake the request. - with mock.patch.object( - type(client.transport.update_vod_config), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.update_vod_config(request=None) + request_init = {"name": "projects/sample1/locations/sample2"} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, "request") as req: + # Designate an appropriate value for the returned response. + return_value = operations_pb2.ListOperationsResponse() - # Establish that the underlying stub method was called. - call.assert_called() - _, args, _ = call.mock_calls[0] - request_msg = video_stitcher_service.UpdateVodConfigRequest() + # Wrap the value into a proper Response obj + response_value = mock.Mock() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + response_value.content = json_return_value.encode("UTF-8") - assert args[0] == request_msg + req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} + response = client.list_operations(request) -def test_transport_kind_grpc_asyncio(): - transport = VideoStitcherServiceAsyncClient.get_transport_class("grpc_asyncio")( - credentials=async_anonymous_credentials() - ) - assert transport.kind == "grpc_asyncio" + # Establish that the response is the type that we expect. + assert isinstance(response, operations_pb2.ListOperationsResponse) -def test_initialize_client_w_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), transport="grpc_asyncio" +def test_initialize_client_w_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" ) assert client is not None # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.create_cdn_key), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_cdn_key(request=None) + client.create_cdn_key(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13698,23 +25846,15 @@ async def test_create_cdn_key_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_cdn_keys_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_cdn_keys_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.list_cdn_keys), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - video_stitcher_service.ListCdnKeysResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - await client.list_cdn_keys(request=None) + client.list_cdn_keys(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13726,23 +25866,15 @@ async def test_list_cdn_keys_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.get_cdn_key), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cdn_keys.CdnKey( - name="name_value", - hostname="hostname_value", - ) - ) - await client.get_cdn_key(request=None) + client.get_cdn_key(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13754,20 +25886,15 @@ async def test_get_cdn_key_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_delete_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.delete_cdn_key), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.delete_cdn_key(request=None) + client.delete_cdn_key(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13779,20 +25906,15 @@ async def test_delete_cdn_key_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_cdn_key_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_cdn_key_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.update_cdn_key), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.update_cdn_key(request=None) + client.update_cdn_key(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13804,30 +25926,17 @@ async def test_update_cdn_key_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_vod_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_vod_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.create_vod_session), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - sessions.VodSession( - name="name_value", - play_uri="play_uri_value", - source_uri="source_uri_value", - ad_tag_uri="ad_tag_uri_value", - asset_id="asset_id_value", - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config="vod_config_value", - ) - ) - await client.create_vod_session(request=None) + client.create_vod_session(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13839,28 +25948,15 @@ async def test_create_vod_session_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_vod_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.get_vod_session), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - sessions.VodSession( - name="name_value", - play_uri="play_uri_value", - source_uri="source_uri_value", - ad_tag_uri="ad_tag_uri_value", - asset_id="asset_id_value", - ad_tracking=live_configs.AdTracking.CLIENT, - vod_config="vod_config_value", - ) - ) - await client.get_vod_session(request=None) + client.get_vod_session(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13872,24 +25968,17 @@ async def test_get_vod_session_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_vod_stitch_details_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_vod_stitch_details_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.list_vod_stitch_details), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - video_stitcher_service.ListVodStitchDetailsResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_vod_stitch_details(request=None) + client.list_vod_stitch_details(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13901,24 +25990,17 @@ async def test_list_vod_stitch_details_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_stitch_detail_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_vod_stitch_detail_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.get_vod_stitch_detail), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - stitch_details.VodStitchDetail( - name="name_value", - ) - ) - await client.get_vod_stitch_detail(request=None) + client.get_vod_stitch_detail(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13930,24 +26012,17 @@ async def test_get_vod_stitch_detail_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_vod_ad_tag_details_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_vod_ad_tag_details_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.list_vod_ad_tag_details), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - video_stitcher_service.ListVodAdTagDetailsResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_vod_ad_tag_details(request=None) + client.list_vod_ad_tag_details(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13959,24 +26034,17 @@ async def test_list_vod_ad_tag_details_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_ad_tag_detail_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_vod_ad_tag_detail_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.get_vod_ad_tag_detail), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - ad_tag_details.VodAdTagDetail( - name="name_value", - ) - ) - await client.get_vod_ad_tag_detail(request=None) + client.get_vod_ad_tag_detail(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -13988,24 +26056,17 @@ async def test_get_vod_ad_tag_detail_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_live_ad_tag_details_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_live_ad_tag_details_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.list_live_ad_tag_details), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - video_stitcher_service.ListLiveAdTagDetailsResponse( - next_page_token="next_page_token_value", - ) - ) - await client.list_live_ad_tag_details(request=None) + client.list_live_ad_tag_details(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14017,24 +26078,17 @@ async def test_list_live_ad_tag_details_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_live_ad_tag_detail_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_live_ad_tag_detail_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.get_live_ad_tag_detail), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - ad_tag_details.LiveAdTagDetail( - name="name_value", - ) - ) - await client.get_live_ad_tag_detail(request=None) + client.get_live_ad_tag_detail(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14046,20 +26100,15 @@ async def test_get_live_ad_tag_detail_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.create_slate), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_slate(request=None) + client.create_slate(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14071,23 +26120,15 @@ async def test_create_slate_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_slates_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_slates_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.list_slates), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - video_stitcher_service.ListSlatesResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - await client.list_slates(request=None) + client.list_slates(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14099,23 +26140,15 @@ async def test_list_slates_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", - ) - - # Mock the actual call, and fake the request. - with mock.patch.object(type(client.transport.get_slate), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - slates.Slate( - name="name_value", - uri="uri_value", - ) - ) - await client.get_slate(request=None) +def test_get_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the actual call, and fake the request. + with mock.patch.object(type(client.transport.get_slate), "__call__") as call: + client.get_slate(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14127,20 +26160,15 @@ async def test_get_slate_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.update_slate), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.update_slate(request=None) + client.update_slate(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14152,20 +26180,15 @@ async def test_update_slate_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_slate_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_delete_slate_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.delete_slate), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.delete_slate(request=None) + client.delete_slate(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14177,27 +26200,17 @@ async def test_delete_slate_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_live_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_live_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.create_live_session), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - sessions.LiveSession( - name="name_value", - play_uri="play_uri_value", - live_config="live_config_value", - ad_tracking=live_configs.AdTracking.CLIENT, - ) - ) - await client.create_live_session(request=None) + client.create_live_session(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14209,25 +26222,15 @@ async def test_create_live_session_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_live_session_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_live_session_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.get_live_session), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - sessions.LiveSession( - name="name_value", - play_uri="play_uri_value", - live_config="live_config_value", - ad_tracking=live_configs.AdTracking.CLIENT, - ) - ) - await client.get_live_session(request=None) + client.get_live_session(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14239,22 +26242,17 @@ async def test_get_live_session_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.create_live_config), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_live_config(request=None) + client.create_live_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14266,25 +26264,17 @@ async def test_create_live_config_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_live_configs_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_live_configs_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.list_live_configs), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - video_stitcher_service.ListLiveConfigsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - await client.list_live_configs(request=None) + client.list_live_configs(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14296,28 +26286,15 @@ async def test_list_live_configs_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.get_live_config), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - live_configs.LiveConfig( - name="name_value", - source_uri="source_uri_value", - ad_tag_uri="ad_tag_uri_value", - state=live_configs.LiveConfig.State.CREATING, - ad_tracking=live_configs.AdTracking.CLIENT, - default_slate="default_slate_value", - stitching_policy=live_configs.LiveConfig.StitchingPolicy.CUT_CURRENT, - ) - ) - await client.get_live_config(request=None) + client.get_live_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14329,22 +26306,17 @@ async def test_get_live_config_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_delete_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.delete_live_config), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.delete_live_config(request=None) + client.delete_live_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14356,22 +26328,17 @@ async def test_delete_live_config_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_live_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_live_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.update_live_config), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.update_live_config(request=None) + client.update_live_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14383,22 +26350,17 @@ async def test_update_live_config_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_create_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_create_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.create_vod_config), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.create_vod_config(request=None) + client.create_vod_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14410,23 +26372,15 @@ async def test_create_vod_config_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_list_vod_configs_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_list_vod_configs_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.list_vod_configs), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - video_stitcher_service.ListVodConfigsResponse( - next_page_token="next_page_token_value", - unreachable=["unreachable_value"], - ) - ) - await client.list_vod_configs(request=None) + client.list_vod_configs(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14438,25 +26392,15 @@ async def test_list_vod_configs_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_get_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_get_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object(type(client.transport.get_vod_config), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - vod_configs.VodConfig( - name="name_value", - source_uri="source_uri_value", - ad_tag_uri="ad_tag_uri_value", - state=vod_configs.VodConfig.State.CREATING, - ) - ) - await client.get_vod_config(request=None) + client.get_vod_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14468,22 +26412,17 @@ async def test_get_vod_config_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_delete_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_delete_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.delete_vod_config), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.delete_vod_config(request=None) + client.delete_vod_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14495,22 +26434,17 @@ async def test_delete_vod_config_empty_call_grpc_asyncio(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. -@pytest.mark.asyncio -async def test_update_vod_config_empty_call_grpc_asyncio(): - client = VideoStitcherServiceAsyncClient( - credentials=async_anonymous_credentials(), - transport="grpc_asyncio", +def test_update_vod_config_empty_call_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", ) # Mock the actual call, and fake the request. with mock.patch.object( type(client.transport.update_vod_config), "__call__" ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - await client.update_vod_config(request=None) + client.update_vod_config(request=None) # Establish that the underlying stub method was called. call.assert_called() @@ -14520,6 +26454,23 @@ async def test_update_vod_config_empty_call_grpc_asyncio(): assert args[0] == request_msg +def test_video_stitcher_service_rest_lro_client(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + transport = client.transport + + # Ensure that we have an api-core operations client. + assert isinstance( + transport.operations_client, + operations_v1.AbstractOperationsClient, + ) + + # Ensure that subsequent calls to the property send the exact same object. + assert transport.operations_client is transport.operations_client + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = VideoStitcherServiceClient( @@ -14678,6 +26629,7 @@ def test_video_stitcher_service_transport_auth_adc(transport_class): [ transports.VideoStitcherServiceGrpcTransport, transports.VideoStitcherServiceGrpcAsyncIOTransport, + transports.VideoStitcherServiceRestTransport, ], ) def test_video_stitcher_service_transport_auth_gdch_credentials(transport_class): @@ -14777,11 +26729,23 @@ def test_video_stitcher_service_grpc_transport_client_cert_source_for_mtls( ) +def test_video_stitcher_service_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch( + "google.auth.transport.requests.AuthorizedSession.configure_mtls_channel" + ) as mock_configure_mtls_channel: + transports.VideoStitcherServiceRestTransport( + credentials=cred, client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + @pytest.mark.parametrize( "transport_name", [ "grpc", "grpc_asyncio", + "rest", ], ) def test_video_stitcher_service_host_no_port(transport_name): @@ -14792,7 +26756,11 @@ def test_video_stitcher_service_host_no_port(transport_name): ), transport=transport_name, ) - assert client.transport._host == ("videostitcher.googleapis.com:443") + assert client.transport._host == ( + "videostitcher.googleapis.com:443" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://videostitcher.googleapis.com" + ) @pytest.mark.parametrize( @@ -14800,6 +26768,7 @@ def test_video_stitcher_service_host_no_port(transport_name): [ "grpc", "grpc_asyncio", + "rest", ], ) def test_video_stitcher_service_host_with_port(transport_name): @@ -14810,7 +26779,120 @@ def test_video_stitcher_service_host_with_port(transport_name): ), transport=transport_name, ) - assert client.transport._host == ("videostitcher.googleapis.com:8000") + assert client.transport._host == ( + "videostitcher.googleapis.com:8000" + if transport_name in ["grpc", "grpc_asyncio"] + else "https://videostitcher.googleapis.com:8000" + ) + + +@pytest.mark.parametrize( + "transport_name", + [ + "rest", + ], +) +def test_video_stitcher_service_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = VideoStitcherServiceClient( + credentials=creds1, + transport=transport_name, + ) + client2 = VideoStitcherServiceClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.create_cdn_key._session + session2 = client2.transport.create_cdn_key._session + assert session1 != session2 + session1 = client1.transport.list_cdn_keys._session + session2 = client2.transport.list_cdn_keys._session + assert session1 != session2 + session1 = client1.transport.get_cdn_key._session + session2 = client2.transport.get_cdn_key._session + assert session1 != session2 + session1 = client1.transport.delete_cdn_key._session + session2 = client2.transport.delete_cdn_key._session + assert session1 != session2 + session1 = client1.transport.update_cdn_key._session + session2 = client2.transport.update_cdn_key._session + assert session1 != session2 + session1 = client1.transport.create_vod_session._session + session2 = client2.transport.create_vod_session._session + assert session1 != session2 + session1 = client1.transport.get_vod_session._session + session2 = client2.transport.get_vod_session._session + assert session1 != session2 + session1 = client1.transport.list_vod_stitch_details._session + session2 = client2.transport.list_vod_stitch_details._session + assert session1 != session2 + session1 = client1.transport.get_vod_stitch_detail._session + session2 = client2.transport.get_vod_stitch_detail._session + assert session1 != session2 + session1 = client1.transport.list_vod_ad_tag_details._session + session2 = client2.transport.list_vod_ad_tag_details._session + assert session1 != session2 + session1 = client1.transport.get_vod_ad_tag_detail._session + session2 = client2.transport.get_vod_ad_tag_detail._session + assert session1 != session2 + session1 = client1.transport.list_live_ad_tag_details._session + session2 = client2.transport.list_live_ad_tag_details._session + assert session1 != session2 + session1 = client1.transport.get_live_ad_tag_detail._session + session2 = client2.transport.get_live_ad_tag_detail._session + assert session1 != session2 + session1 = client1.transport.create_slate._session + session2 = client2.transport.create_slate._session + assert session1 != session2 + session1 = client1.transport.list_slates._session + session2 = client2.transport.list_slates._session + assert session1 != session2 + session1 = client1.transport.get_slate._session + session2 = client2.transport.get_slate._session + assert session1 != session2 + session1 = client1.transport.update_slate._session + session2 = client2.transport.update_slate._session + assert session1 != session2 + session1 = client1.transport.delete_slate._session + session2 = client2.transport.delete_slate._session + assert session1 != session2 + session1 = client1.transport.create_live_session._session + session2 = client2.transport.create_live_session._session + assert session1 != session2 + session1 = client1.transport.get_live_session._session + session2 = client2.transport.get_live_session._session + assert session1 != session2 + session1 = client1.transport.create_live_config._session + session2 = client2.transport.create_live_config._session + assert session1 != session2 + session1 = client1.transport.list_live_configs._session + session2 = client2.transport.list_live_configs._session + assert session1 != session2 + session1 = client1.transport.get_live_config._session + session2 = client2.transport.get_live_config._session + assert session1 != session2 + session1 = client1.transport.delete_live_config._session + session2 = client2.transport.delete_live_config._session + assert session1 != session2 + session1 = client1.transport.update_live_config._session + session2 = client2.transport.update_live_config._session + assert session1 != session2 + session1 = client1.transport.create_vod_config._session + session2 = client2.transport.create_vod_config._session + assert session1 != session2 + session1 = client1.transport.list_vod_configs._session + session2 = client2.transport.list_vod_configs._session + assert session1 != session2 + session1 = client1.transport.get_vod_config._session + session2 = client2.transport.get_vod_config._session + assert session1 != session2 + session1 = client1.transport.delete_vod_config._session + session2 = client2.transport.delete_vod_config._session + assert session1 != session2 + session1 = client1.transport.update_vod_config._session + session2 = client2.transport.update_vod_config._session + assert session1 != session2 def test_video_stitcher_service_grpc_transport_channel(): @@ -15949,8 +28031,21 @@ async def test_transport_close_grpc_asyncio(): close.assert_called_once() +def test_transport_close_rest(): + client = VideoStitcherServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="rest" + ) + with mock.patch.object( + type(getattr(client.transport, "_session")), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + def test_client_ctx(): transports = [ + "rest", "grpc", ] for transport in transports: